/** * https://github.com/yiisoft/yii/issues/2435 */ public function testEmbedExpiry() { $app = new TestApplication(array('id' => 'testApp', 'components' => array('cache' => array('class' => 'CFileCache')))); $app->reset(); $cache = $app->cache; $cache->set('testKey1', 'testValue1', 2); $files = glob(Yii::getPathOfAlias('application.runtime.cache') . '/*.bin'); $this->assertEquals(time() + 2, filemtime($files[0])); $cache->set('testKey2', 'testValue2', 2); sleep(1); $this->assertEquals('testValue2', $cache->get('testKey2')); $cache->set('testKey3', 'testValue3', 2); sleep(3); $this->assertEquals(false, $cache->get('testKey2')); $app = new TestApplication(array('id' => 'testApp', 'components' => array('cache' => array('class' => 'CFileCache', 'embedExpiry' => true)))); $app->reset(); $cache = $app->cache; $cache->set('testKey4', 'testValue4', 2); $files = glob(Yii::getPathOfAlias('application.runtime.cache') . '/*.bin'); $this->assertEquals(time(), filemtime($files[0])); $cache->set('testKey5', 'testValue5', 2); sleep(1); $this->assertEquals('testValue5', $cache->get('testKey5')); $cache->set('testKey6', 'testValue6', 2); sleep(3); $this->assertEquals(false, $cache->get('testKey6')); }
public function setUp() { if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) { $this->markTestSkipped('PDO and SQLite extensions are required.'); } // clean up runtime directory $app = new TestApplication(); $app->reset(); }
public function testEncryptionKey() { $sm = new CSecurityManager(); $key = '123456'; $sm->encryptionKey = $key; $this->assertEquals($key, $sm->encryptionKey); $app = new TestApplication(); $key = $app->securityManager->encryptionKey; $app->saveGlobalState(); $app2 = new TestApplication(); $this->assertEquals($app2->securityManager->encryptionKey, $key); }
public function testExpire() { $app = new TestApplication($this->_config1); $app->reset(); $cache = $app->cache; $data = array('abc' => 1, 2 => 'def'); $key = 'data3'; $cache->set($key, $data, 2); $this->assertTrue($cache->get($key) === $data); sleep(4); $app2 = new TestApplication($this->_config1); $this->assertFalse($app2->cache->get($key)); }
public function testPublishFile() { $app = new TestApplication(); $app->reset(); $am = new CAssetManager(); $am->init($app); $path1 = $am->getPublishedPath(__FILE__); clearstatcache(); $this->assertFalse(is_file($path1)); $url = $am->publish(__FILE__); $path2 = $am->getPublishedPath(__FILE__); $this->assertEquals($path1, $path2); clearstatcache(); $this->assertTrue(is_file($path1)); $this->assertEquals(basename($path1), basename(__FILE__)); $this->assertEquals($url, $am->baseUrl . '/' . basename(dirname($path2)) . '/' . basename($path2)); }
$t->is($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists'); try { $application->findNamespace('f'); $t->fail('->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous'); } catch (\InvalidArgumentException $e) { $t->pass('->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous'); } try { $application->findNamespace('bar'); $t->fail('->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace'); } catch (\InvalidArgumentException $e) { $t->pass('->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace'); } // ->findCommand() $t->diag('->findCommand()'); $application = new TestApplication(); $application->addCommand(new FooCommand()); $t->is(get_class($application->findCommand('foo:bar')), 'FooCommand', '->findCommand() returns a command if its name exists'); $t->is(get_class($application->findCommand('h')), 'Symfony\\Components\\CLI\\Command\\HelpCommand', '->findCommand() returns a command if its name exists'); $t->is(get_class($application->findCommand('f:bar')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace exists'); $t->is(get_class($application->findCommand('f:b')), 'FooCommand', '->findCommand() returns a command if the abbreviation for the namespace and the command name exist'); $t->is(get_class($application->findCommand('a')), 'FooCommand', '->findCommand() returns a command if the abbreviation exists for an alias'); $application->addCommand(new Foo1Command()); $application->addCommand(new Foo2Command()); try { $application->findCommand('f'); $t->fail('->findCommand() throws an \\InvalidArgumentException if the abbreviation is ambiguous for a namespace'); } catch (\InvalidArgumentException $e) { $t->pass('->findCommand() throws an \\InvalidArgumentException if the abbreviation is ambiguous for a namespace'); } try {
public function testExpire2() { $app = new TestApplication($this->_config); $app->reset(); $cache = $app->cache; $data = array('xyz' => 3, 4 => 'mnp'); $key = 'data3_2'; $cache->set($key, $data, 5); $this->assertTrue($cache->get($key) === $data); sleep(2); $app2 = new TestApplication($this->_config); $this->assertEquals($data, $app2->cache->get($key)); }
function testBooted() { $app = new TestApplication(__DIR__ . "/app", "/tmp"); $app->run(); $this->assertTrue($app->config->booted); }
public function setUp() { // clean up runtime directory $app = new TestApplication(); $app->reset(); }
public function testValidateRequestSuccess() { $primedRequest = Mockery::mock('\\Stubber\\Primer\\Request'); $primedRequest->shouldReceive('getMethod')->andReturn(0); $primedRequest->shouldReceive('getPath')->andReturn(0); $primedRequest->shouldReceive('getQuery')->andReturn(0); $request = Mockery::mock('\\React\\Http\\Request'); $request->shouldReceive('getMethod')->andReturn(0); $request->shouldReceive('getPath')->andReturn(0); $request->shouldReceive('getQuery')->andReturn(0); $server = Mockery::mock('\\Stubber\\Server'); $server->shouldReceive('setApplication')->andReturn($server); $application = new TestApplication($server); $application->validateRequest($primedRequest, $request); }