<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 16/6/25
 * Time: 下午4:00
 */

define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));

require_once(BASE_ROOT_PATH . '/fooder.php');
require_once(BASE_ROOT_PATH . '/helper/relation_helper.php');
require_once(BASE_ROOT_PATH . '/helper/session_helper.php');


class user_helperTest extends PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        Base::run_util();
    }

    public function testUpContacts()
    {
//        $datas = array('13911129867','13911129868','13911129869','13911129870','13911129870');
//        $jsData = json_encode($datas);
//        $jsData = urlencode($jsData);
//        session_helper::parse_contacts($jsData);
    }

    public function testSocket()
    {
        $socket = stream_socket_client ("tcp://192.168.1.105:2000");

        $data = array('type' => 1,'keyword' => "美白");
        $data = serialize($data);

        $i = 0;
        while ($i < 10000) {
            $len = sprintf("%010d",strlen($data));
            stream_socket_sendto($socket,$len . $data);
            $i++;
        }
        stream_socket_shutdown($socket,STREAM_SHUT_RDWR);
    }

    public function testEAS()
    {
        $socket = stream_socket_client ("tcp://58.246.76.195:6888");
        $ret = fwrite($socket,'test usable');
        $tmp = fread($socket,1024);

        $y = $socket;
    }

    public function testLen()
    {
        $x = sprintf("%010d",500);
        $y = intval($x);

        $read = "";
        while ($read) {
            echo "erad";
        }
    }

    public function testImage()
    {
        $ret = getimagesize("http://192.168.0.200/data/upload/mobile/special/s0/s0_05300358745765788.png",$imginfo);
    }

    public function testActivity()
    {
        //require_once ('/Users/stanley-king/work/PHPProject/shopnc/mobile/control/activity.php');

        $x = 'http://a.lrlz.com/mobile/index.php?act=activity&amp;op=limit_entra';
        $y = htmlspecialchars_decode($x);

        $x = 'http://a.lrlz.com/mobile/index.php?act=activity&op=limit_entra';
        $y = htmlspecialchars($x);
    }

    public function testKeysort()
    {
        $data = array(10 => 3018.25,90 => 5623,30 => 5566);

        ksort($data);

        $xdata = $data;
        krsort($xdata);
    }

    public function testPath()
    {
        $path = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/shop/store/goods/6/6_05215748240985301_240.jpg';
        $info = pathinfo($path);

    }
}
