<?php

include_once './framework/doctrinetestcase.php';
class StoreServiceTest extends DoctrineTestCase
{
    public function Run()
    {
        include_once '../InitData.ini.php';
        $typeAndRate = array();
        foreach ($PowerupTypes as $value) {
            $typeAndRate[$value[0]] = $value[3];
        }
        $amount = 1;
        $typeCollection = Utility\CommonUtility::GetRandomPowerUpsType($typeAndRate, $amount);
        $this->AssertEquals(count($typeCollection), $amount, "get random {$amount} powerup failed");
        $amount = 5;
        $typeCollection = Utility\CommonUtility::GetRandomPowerUpsType($typeAndRate, $amount);
        $this->AssertEquals(count($typeCollection), $amount, "get random {$amount} powerup failed");
        $amount = 11;
        $typeCollection = Utility\CommonUtility::GetRandomPowerUpsType($typeAndRate, $amount);
        $this->AssertEquals(count($typeCollection), $amount, "get random {$amount} powerup failed");
    }
}
$suite = new TestSuite();
$suite->AddTest('StoreServiceTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
<?php

require_once '../odmconfig.php';
include_once './framework/php_unit_test.php';
require_once './framework/xhtml_test_runner.php';
require_once './framework/text_test_runner.php';
require_once './framework/xml_test_runner.php';
require_once './framework/console_test_runner.php';
class GearmanTest extends TestCase
{
    public function SetUp()
    {
    }
    public function TearDown()
    {
    }
    public function Run()
    {
        /* create our object */
        $gmclient = new \GearmanClient();
        /* add the default server */
        $gmclient->addServer();
        /* run reverse client */
        $job_handle = $gmclient->doBackground("reverse", "this is a test");
    }
}
$suite = new TestSuite();
$suite->AddTest('GearmanTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
include_once './framework/doctrinetestcase.php';
class UserTest extends DoctrineTestCase
{
    private $m = NULL;
    private $db;
    private $users;
    public function SetUp()
    {
        $this->m = new \Mongo();
        $this->db = $this->m->bingo;
        $this->users = $this->db->User;
        $this->users->drop();
    }
    public function Run()
    {
        $user = new Models\User();
        $user->name = 'winston';
        $this->doctrinemodel->persist($user);
        $this->doctrinemodel->flush();
        $userfind = $this->doctrinemodel->createQueryBuilder('Models\\User')->field('name')->equals('winston')->getQuery()->getSingleResult();
        $this->AssertEquals($userfind->name, 'winston', 'User name not equal');
    }
    public function TearDown()
    {
        $this->users->drop();
    }
}
$suite = new TestSuite();
$suite->AddTest('UserTest');
$runner = new TextTestRunner();
$runner->Run($suite);
        $this->AssertEquals($result, TRUE, 'publish message failed');
        $msgbody3 = 'hello player3';
        // Publish a message to the exchange with a routing key
        $result = $ex->publish($msgbody3, 'queue3.command');
        $this->AssertEquals($result, TRUE, 'publish message failed');
        // Read from the queue
        $msg = $q1->consume($options);
        $this->AddMessage(var_export($msg, true));
        $this->AssertEquals(count($msg), 2);
        $this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
        $this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
        // Read from the queue
        $msg = $q2->consume($options);
        $this->AssertEquals(count($msg), 2);
        $this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
        $this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
        // Read from the queue
        $msg = $q3->consume($options);
        $this->AddMessage(var_export($msg, true));
        $this->AssertEquals(count($msg), 3);
        $this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
        $this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
        $this->AssertEquals($msg[2]['message_body'], $msgbody3, 'message not equal');
        $msg = $q3->consume($options);
        $this->AssertEquals(count($msg), 0);
    }
}
$suite = new TestSuite();
$suite->AddTest('AMQPTopicTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
        $register = $login->Register($this->AddQuote($username)
        							, $this->AddQuote($pwd) 
        							, $this->AddQuote('*****@*****.**')
        							, $this->AddQuote($registerNonce->_sessionId)
        							, $this->AddQuote($registerNonce->_nonce));
        
        $this->AssertEquals($register->_returnCode, Constant\ErrorCode::OK, 'Register not successfully');
        
        
        
        $nonce = $login->GetNonce($this->AddQuote($username));
        	    $this->AssertEquals(strlen($nonce->_nonce), 6, 'Login not successfully');	
        	    
        $cnonce = "abcdef";
        
        $pwdfromclient = md5($nonce->_nonce.$cnonce.$decrypt);
        
        $result = $login->Login($username,$pwdfromclient,$cnonce);
        $this->AssertEquals($result->_returnCode, Constant\ErrorCode::OK, 'Login not successfully');		
        */
    }
    public function TearDown()
    {
        //$this->users->drop();
    }
}
$suite = new TestSuite();
$suite->AddTest('LoginServiceTest');
$runner = new ConsoleTestRunner();
//$runner = new TextTestRunner();
$runner->Run($suite, false);
{
    public function Run()
    {
        $a = new \Models\A();
        $this->doctrinemodel->persist($a);
        $this->doctrinemodel->flush();
        $this->AddMessage(gettype($a->getDoccol()));
        $this->AddMessage(gettype($a->getNatcol()));
        $this->AddMessage(gettype($a->getBs()));
        $a->addDoccol(1);
        $a->mergeDoccol(array(2, 3));
        //array_push($a->getNatcol(), 1);
        $this->doctrinemodel->flush();
    }
}
class DoctrineTestIncrement extends DoctrineTestCase
{
    public function Run()
    {
        for ($i = 1; $i < 100; $i++) {
            $c = new \Models\C();
            $c->value = str_repeat($i, 10);
            $this->doctrinemodel->persist($c);
        }
        $this->doctrinemodel->flush();
    }
}
$suite = new TestSuite();
$suite->AddTest('DoctrineTestIncrement');
$runner = new TextTestRunner();
$runner->Run($suite, false);
<?php

require_once '../odmconfig.php';
include_once './framework/php_unit_test.php';
require_once './framework/xhtml_test_runner.php';
require_once './framework/text_test_runner.php';
require_once './framework/xml_test_runner.php';
require_once './framework/console_test_runner.php';
class MemcacheTest extends TestCase
{
    public function SetUp()
    {
    }
    public function TearDown()
    {
    }
    public function Run()
    {
        $memcache = new \Memcache();
        $this->AssertEquals($memcache->connect('localhost', 11211), TRUE, 'connect');
        $memcache->set('testkey', 'testvalue', MEMCACHE_COMPRESSED);
        $this->AssertEquals($memcache->get('testkey'), 'testvalue');
    }
}
$suite = new TestSuite();
$suite->AddTest('MemcacheTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
        $this->AssertEquals($gamecard->daubAll($userDaubNumbers), \Constant\ErrorCode::OK, 'Daub all failed');
        $this->doctrinemodel->flush();
        $this->AssertEquals($gamecard->evaluateResult(range(1, 75)), \Constant\GameResult::Failed, 'evaluateResult not win');
        // add the instant win number
        array_push($gamecard->autoDaubNumberList, $singleDaubNumber);
        $this->AssertEquals($gamecard->evaluateResult(range(1, 75)), \Constant\GameResult::Win, 'evaluateResult not win');
        // check the second gameboard for double daub
        $secondGameCard = $newGameRound->getCardForUser($user, 1);
        $newUserCard = $secondGameCard->getUserCard();
        $newGameRound->currentCallNumberIndex = 75;
        $userDaubNumbers = $newUserCard[0];
        $firstDaubNumber = $userDaubNumbers[count($userDaubNumbers) - 1];
        $secondDaubNumber = $userDaubNumbers[count($userDaubNumbers) - 2];
        array_pop($userDaubNumbers);
        // remove the last number
        array_pop($userDaubNumbers);
        $this->AssertEquals($secondGameCard->daubAll($userDaubNumbers), \Constant\ErrorCode::OK, 'Daub all failed');
        $this->doctrinemodel->flush();
        $this->AssertEquals($secondGameCard->evaluateResult(range(1, 75)), \Constant\GameResult::Failed, 'evaluateResult not win');
        array_push($secondGameCard->autoDaubNumberList, $firstDaubNumber);
        array_push($secondGameCard->secondDaubNumberList, $secondDaubNumber);
        $this->AssertEquals($secondGameCard->evaluateResult(range(1, 75)), \Constant\GameResult::Win, 'evaluateResult not win');
    }
}
$suite = new TestSuite();
$suite->AddTest('GameCardStaticTest');
$suite->AddTest('GameCardGeneraterTest');
$suite->AddTest('GameCardInstantWinTest');
$suite->AddTest('GameCardSinagleDauborDoubleDaubTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
include_once './framework/doctrinetestcase.php';
include_once '../amfphp/services/VersionService.php';
include_once '../lib/Constant/ErrorCode.php';
class VersionServiceTest extends DoctrineTestCase
{
    public function SetUp()
    {
    }
    public function Run()
    {
        $version = new VersionService();
        $platform = 'iPad';
        $currentVersion = '0.9';
        $result = $version->NeedUpdate($this->AddQuote($platform), $this->AddQuote($currentVersion));
        $this->AssertEquals($result->_returnCode, Constant\ErrorCode::VersionNeedUpdate, 'Need update');
        $platform = 'iPad';
        $currentVersion = '1.2';
        $result = $version->NeedUpdate($this->AddQuote($platform), $this->AddQuote($currentVersion));
        $this->AssertEquals($result->_returnCode, Constant\ErrorCode::OK, 'No Need update');
        $platform = 'abc';
        $result = $version->NeedUpdate($this->AddQuote($platform), $this->AddQuote($currentVersion));
        $this->AssertEquals($result->_returnCode, Constant\ErrorCode::VersionUnkownPlatform, 'Unkown platform');
    }
    public function TearDown()
    {
    }
}
$suite = new TestSuite();
$suite->AddTest('VersionServiceTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
        $this->doctrinemodel->flush();
        $gameRound->Initialize();
        $userboards = $gameRound->getUserBoards();
        $callnumbers = $gameRound->getCallNumber();
        $this->AssertEquals(count($callnumbers), 10, 'call number equal 10');
        $this->AssertEquals(count($userboards), 1, 'user boards equal 1');
        $this->AssertEquals(count($userboards[$user->id]), 25, 'userboard size equal 25');
        $gameRound2 = new Models\GameRound($gameRoom, 11, 25);
        $this->doctrinemodel->persist($gameRound2);
        $this->doctrinemodel->flush();
        $gameRound2->Initialize();
        // Join game for user2
        $this->AssertEquals($gameRoom->ConnectUser($user2), TRUE, 'Call ConnectUser for user2');
        $userboards = $gameRound2->getUserBoards();
        $callnumbers = $gameRound2->getCallNumber();
        $this->AssertEquals(count($callnumbers), 11, 'call number equal 11');
        $this->AssertEquals(count($userboards), 1, 'user boards equal 1');
        $this->AssertEquals(count($userboards[$user->id]), 25, 'user2 userboard size equal 25');
        $this->AssertEquals(count($userboards[$user2->id]), 25, 'user2 userboard size equal 25');
    }
    public function TearDown()
    {
        $this->gameroom->drop();
        $this->users->drop();
        $this->gameround->drop();
    }
}
$suite = new TestSuite();
$suite->AddTest('GameRoundTest');
$runner = new TextTestRunner();
$runner->Run($suite, true);
Example #11
0
    {
        // Declare a new exchange
        $ex = new AMQPExchange($this->cnn);
        $ex->declare('game', AMQP_EX_TYPE_FANOUT);
        // Create a new queue
        $q1 = new AMQPQueue($this->cnn);
        $q1->declare('queue1');
        $q2 = new AMQPQueue($this->cnn);
        $q2->declare('queue2');
        // Bind it on the exchange to routing.key
        //$ex->bind('queue1', 'broadcast=true,target=queue1,x-match=any');
        $ex->bind('queue1', '');
        $ex->bind('queue2', '');
        $msgBody = 'hello';
        // Publish a message to the exchange with a routing key
        $ex->publish($msgBody, 'foo');
        // Read from the queue
        $msg = $q1->consume();
        $this->AssertEquals(count($msg), 1);
        $this->AssertEquals($msg[0]['message_body'], $msgBody, 'message not equal');
        // Read from the queue
        $msg = $q2->consume();
        $this->AssertEquals(count($msg), 1);
        $this->AssertEquals($msg[0]['message_body'], $msgBody, 'message not equal');
        $this->AddMessage(var_export($msg[0], true));
    }
}
$suite = new TestSuite();
$suite->AddTest('AMQPDirectExOneQueueTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
        $this->GCCollectCycle();
        $this->PrintMemoryOverview();
    }
}
class DoctrineMemoryLeakTest extends MemoryLeakBaseTestCase
{
    public function Run()
    {
        ob_implicit_flush(TRUE);
        for ($i = 0; $i < 10; $i++) {
            $this->PrintMemoryOverview();
            $users = $this->doctrinemodel->getRepository('Models\\User')->findAll();
            foreach ($users as $user) {
                echo 'Found User: '******'NormalMemoryLeakTest');
$suite->AddTest('DoctrineMemoryLeakTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
Example #13
0
        $this->AssertEquals(is_object($this->createThing), true, $message = 'create thing');
        // then lets make sure it returns with a 200 status code
        $this->AssertEquals($this->showPerson->http_code, 200, $message = 'show person status code');
        $this->AssertEquals($this->findPerson->http_code, 200, $message = 'find person status code');
        $this->AssertEquals($this->createPerson->http_code, 200, $message = 'create person status code');
        $this->AssertEquals($this->showPlace->http_code, 200, $message = 'show place status code');
        $this->AssertEquals($this->findPlace->http_code, 200, $message = 'find place status code');
        $this->AssertEquals($this->createPlace->http_code, 200, $message = 'create place status code');
        $this->AssertEquals($this->showThing->http_code, 200, $message = 'show thing status code');
        $this->AssertEquals($this->findThing->http_code, 200, $message = 'find thing status code');
        $this->AssertEquals($this->createThing->http_code, 200, $message = 'create thing status code');
        // finally lets check the content type
        $this->AssertEquals($this->showPerson->http_info['content_type'], 'application/json; charset=utf-8', $message = 'show person content type');
        $this->AssertEquals($this->findPerson->http_info['content_type'], 'application/json; charset=utf-8', $message = 'find person content type');
        $this->AssertEquals($this->createPerson->http_info['content_type'], 'application/json; charset=utf-8', $message = 'create person content type');
        $this->AssertEquals($this->showPlace->http_info['content_type'], 'application/json; charset=utf-8', $message = 'show place content type');
        $this->AssertEquals($this->findPlace->http_info['content_type'], 'application/json; charset=utf-8', $message = 'find place content type');
        $this->AssertEquals($this->createPlace->http_info['content_type'], 'application/json; charset=utf-8', $message = 'create place content type');
        $this->AssertEquals($this->showThing->http_info['content_type'], 'application/json; charset=utf-8', $message = 'show thing content type');
        $this->AssertEquals($this->findThing->http_info['content_type'], 'application/json; charset=utf-8', $message = 'find thing content type');
        $this->AssertEquals($this->createThing->http_info['content_type'], 'application/json; charset=utf-8', $message = 'create thing content type');
    }
    public function TearDown()
    {
        unset($hyperpublic);
    }
}
$suite = new TestSuite();
$suite->AddTest('HyperpublicTest');
$runner = new TextTestRunner();
$runner->Run($suite, 'result');
        $this->doctrinemodel->flush();
        $groomFind = $this->doctrinemodel->getRepository('Models\\GameRoom')->findOneBy(array('name' => $gamename));
        $this->AssertEquals($groomFind->name, $gamename, 'gameroom persist');
        // User persist
        $user = new Models\User();
        $user->name = $username;
        $this->doctrinemodel->persist($user);
        $this->doctrinemodel->flush();
        $userFind = $this->doctrinemodel->getRepository('Models\\User')->findOneBy(array('name' => $username));
        $this->AssertEquals($userFind->name, $username, 'user persist');
        // Join Game
        $this->AssertEquals($groomFind->ConnectUser($userFind), TRUE, 'Call ConnectUser');
        $this->AssertEquals($groomFind->getConnectedUsers()->count(), 1);
        $this->AssertEquals($groomFind->getConnectedUsers()->contains($userFind), TRUE, 'Join Game');
        $this->AssertEquals($groomFind->DisconnectUser($userFind), TRUE, 'Call DisconnectUser');
        $this->AssertEquals($groomFind->getConnectedUsers()->count(), 0, 'Exit game user count');
        $this->AssertEquals($groomFind->getConnectedUsers()->contains($userFind), FALSE, 'Exit Game');
        $groomFind->ResetUsers();
        $this->AssertEquals($groomFind->getConnectedUsers()->count(), 0);
        $this->AssertEquals($groomFind->getConnectedUsers()->contains($userFind), FALSE, 'Reset Game Users');
    }
    public function TearDown()
    {
        $this->gameroom->drop();
        $this->users->drop();
    }
}
$suite = new TestSuite();
$suite->AddTest('GameRoomTest');
$runner = new TextTestRunner();
$runner->Run($suite, true);
<?php

require_once '../odmconfig.php';
include_once './framework/amqptestcase.php';
class AMQPEventTest extends AMQPTestCase
{
    public function Run()
    {
        // Create a new queue
        $q1 = new AMQPQueue($this->cnn);
        $q1->declare('queue1');
        $q1->purge('queue1');
        $options = array('min' => 0, 'max' => 10, 'ack' => true);
        // Bind it on the exchange to routing.key
        $q1->bind(\Constant\AMQPChannelConstant::AMF, \Constant\AMQPCommand::BingoBroadcast);
        // Read from the queue
        while (TRUE) {
            $msg = $q1->consume($options);
            var_dump($msg);
        }
    }
}
$suite = new TestSuite();
$suite->AddTest('AMQPEventTest');
$runner = new TextTestRunner();
$runner->Run($suite, false);
        $msgbody2 = 'world';
        // Publish a message to the exchange with a routing key
        $result = $ex->publish($msgbody2, NULL, AMQP_IMMEDIATE, array('headers' => array('broadcast' => 1)));
        $this->AssertEquals($result, TRUE, 'publish message failed');
        $msgbody3 = 'queue3';
        // Publish a message to the exchange with a routing key
        $result = $ex->publish($msgbody1, NULL, AMQP_IMMEDIATE, array('headers' => array('target' => 3)));
        $this->AssertEquals($result, TRUE, 'publish message failed');
        // Read from the queue
        $msg = $q1->consume($options);
        $this->AddMessage(var_export($msg, true));
        $this->AssertEquals(count($msg), 2);
        //$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
        //$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
        // Read from the queue
        $msg = $q2->consume($options);
        $this->AssertEquals(count($msg), 2);
        //$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
        //$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
        // Read from the queue
        $msg = $q3->consume($options);
        $this->AssertEquals(count($msg), 3);
        //$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
        //$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
        //$this->AssertEquals($msg[2]['message_body'], $msgbody3, 'message not equal');
    }
}
$suite = new TestSuite();
$suite->AddTest('AMQPXMatchTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);
<?php

require_once '../odmconfig.php';
include_once './framework/doctrinetestcase.php';
class DoctrineUpdateTest extends DoctrineTestCase
{
    public function SetUp()
    {
        //
    }
    public function TearDown()
    {
        //
    }
    public function Run()
    {
        $aFound = $this->doctrinemodel->createQueryBuilder('Models\\A')->getQuery()->getSingleResult();
        $this->AssertNotEquals($aFound, NULL);
        $aFound->intAValue = $aFound->intAValue + 100;
        $aFound->stringAValue = $aFound->stringAValue . '__aa__';
        $this->doctrinemodel->flush();
    }
}
$suite = new TestSuite();
$suite->AddTest('DoctrineUpdateTest');
$runner = new ConsoleTestRunner();
$runner->Run($suite, false);