Ejemplo n.º 1
0
 function testGetAll()
 {
     $this->wrapper->purge();
     $this->wrapper->set('aloframework', 'just works');
     $getall = $this->wrapper->getAll();
     $this->assertEquals(['aloframework' => 'just works'], $getall, _unit_dump($getall));
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider testEqualsProvider
  */
 function testEquals($method, $val)
 {
     $r = new Router();
     $r->initNoCall();
     $call = call_user_func([$r, $method]);
     $this->assertEquals($val, $call, _unit_dump(['method' => $method, 'expected' => $val, 'actual' => $call]));
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider falseProvider
  */
 function testFalse($validationCriteria, $validatedValue, $exptOutcome = true)
 {
     $f = new F(['foo' => $validatedValue]);
     $f->bind('foo', [$validationCriteria => $exptOutcome]);
     $f->evaluate();
     $eval = $f->getEvaluation();
     $this->assertFalse($eval['OK'], _unit_dump(['$validatedValue' => $validatedValue, '$validationCriteria' => $validationCriteria, '$exptOutcome' => $exptOutcome, '$eval' => $eval]));
 }
Ejemplo n.º 4
0
 function testIsJSON()
 {
     $true = ['"foo"', 'true', 'false', '[1,2,3]', '[]', '{}', '{"foo":1}'];
     $false = ['foo', [], '{foo: bar}'];
     foreach ($true as $v) {
         $this->assertTrue(Format::isJSON($v), _unit_dump($v));
     }
     foreach ($false as $v) {
         $this->assertFalse(Format::isJSON($v), _unit_dump($v));
     }
 }
Ejemplo n.º 5
0
 function testAutocommitAndGetAtIndex()
 {
     if ($this->available) {
         PhuGlobal::$cron->autocommit(true)->clearCrontab()->appendCrontab('php foo.php');
         $get = PhuGlobal::$cron->reloadCrontab()->getCrontab();
         $this->assertEquals(1, count($get), _unit_dump($get));
         PhuGlobal::$cron->appendCrontab('php bar.php')->reloadCrontab();
         $this->assertEquals('* * * * * php foo.php', PhuGlobal::$cron->getAtIndex(0));
         $this->assertEquals('* * * * * php bar.php', PhuGlobal::$cron->getAtIndex(1));
     }
 }
Ejemplo n.º 6
0
 function testSave()
 {
     AbstractSession::destroySafely();
     call_user_func($this->handler . '::init', $this->wrapper);
     $_SESSION['foo'] = 'bar';
     $id = session_id();
     session_write_close();
     $sessFetched = $this->wrapper->get($this->prefix . $id);
     $this->assertNotEmpty($sessFetched, _unit_dump(['id' => $id, 'fetched' => $sessFetched, 'all' => $this->wrapper->getAll(), 'is_available' => $this->wrapper->isAvailable()]));
     $this->assertTrue(stripos($sessFetched, 'foo') !== false, '"foo" not found in session data');
     $this->assertTrue(stripos($sessFetched, 'bar') !== false, '"bar" not found in session data');
 }
Ejemplo n.º 7
0
 function testSave()
 {
     MySQLSession::destroySafely();
     MySQLSession::init(PhuGlobal::$mysql);
     $_SESSION['foo'] = 'bar';
     $id = session_id();
     session_write_close();
     $sql = 'SELECT `data` FROM `alo_session` WHERE `id`=?';
     $sqlParams = [$id];
     $sessFetched = PhuGlobal::$mysql->prepQuery($sql, $sqlParams, [mySQL::V_CACHE => false]);
     $this->assertNotEmpty($sessFetched, _unit_dump(['sql' => $sql, 'params' => $sqlParams, 'fetched' => $sessFetched, 'all' => PhuGlobal::$mysql->prepQuery('SELECT * FROM `alo_session`')]));
     $sessFetched = $sessFetched[0]['data'];
     $this->assertTrue(stripos($sessFetched, 'foo') !== false, '"foo" not found in session data');
     $this->assertTrue(stripos($sessFetched, 'bar') !== false, '"bar" not found in session data');
     ob_flush();
 }
Ejemplo n.º 8
0
 function testCache()
 {
     $this->cache->purge();
     self::createSQL();
     $prepSQL = 'INSERT INTO `test_table` VALUES (?), (?), (?)';
     $prepParams = [1, 2, 3];
     $agSQL = 'SELECT SUM(`key0`) FROM `test_table`';
     $agSettings = [MySQL::V_CACHE => true, MySQL::V_TIME => 20];
     PhuGlobal::$mysql->prepQuery($prepSQL, $prepParams);
     $agg = PhuGlobal::$mysql->aggregate($agSQL, null, $agSettings);
     $lastHash = PhuGlobal::$mysql->getLastHash();
     $getAll = $this->cache->getAll();
     $get = $this->cache->get($lastHash);
     $this->assertArrayHasKey($lastHash, $getAll, _unit_dump(['lastHash' => $lastHash, 'getAll' => $getAll]));
     $this->assertEquals($agg, $get, _unit_dump(['aggregate' => $agg, 'get' => $get]));
     self::deleteSQL();
 }
Ejemplo n.º 9
0
 function testEquals()
 {
     $expected = ['glob_one' => 'one', 'glob_two' => 'two', 'loc_three' => 'three', 'loc_four' => 'keturi'];
     $actual = PhuGlobal::$locale->getAll();
     $this->assertEquals($expected, $actual, _unit_dump(['expected' => $expected, 'actual' => $actual]));
 }