示例#1
0
 public function setUp()
 {
     if (Translator\Translator::hasCache()) {
         Translator\Translator::removeCache();
     }
     if (Adapter\ArrayAdapter::hasCache()) {
         Adapter\ArrayAdapter::removeCache();
     }
 }
示例#2
0
 public function tearDown()
 {
     if (Translator\Translator::hasCache()) {
         Translator\Translator::clearCache();
         Translator\Translator::removeCache();
     }
     if (Adapter\ArrayAdapter::hasCache()) {
         Adapter\ArrayAdapter::clearCache();
         Adapter\ArrayAdapter::removeCache();
     }
 }
示例#3
0
 public function tearDown()
 {
     if (Translator\Translator::hasCache()) {
         Translator\Translator::clearCache();
         Translator\Translator::removeCache();
     }
     if (Adapter\ArrayAdapter::hasCache()) {
         Adapter\ArrayAdapter::clearCache();
         Adapter\ArrayAdapter::removeCache();
     }
     $this->_removeRecursive($this->_cacheDir);
 }
示例#4
0
 public function setUp()
 {
     // Arrays representing common config configurations
     $this->nested = array('a' => 1, 'b' => 2, 'c' => array('ca' => 3, 'cb' => 4, 'cc' => 5, 'cd' => array('cda' => 6, 'cdb' => 7)), 'd' => array('da' => 8, 'db' => 9), 'e' => 10);
     $this->tokenBare = array('simple' => 'BARETOKEN', 'inside' => 'some text with BARETOKEN inside', 'nested' => array('simple' => 'BARETOKEN', 'inside' => 'some text with BARETOKEN inside'));
     $this->tokenPrefix = array('simple' => '::TOKEN', 'inside' => ':: some text with ::TOKEN inside ::', 'nested' => array('simple' => '::TOKEN', 'inside' => ':: some text with ::TOKEN inside ::'));
     $this->tokenSuffix = array('simple' => 'TOKEN::', 'inside' => ':: some text with TOKEN:: inside ::', 'nested' => array('simple' => 'TOKEN::', 'inside' => ':: some text with TOKEN:: inside ::'));
     $this->tokenSurround = array('simple' => '##TOKEN##', 'inside' => '## some text with ##TOKEN## inside ##', 'nested' => array('simple' => '##TOKEN##', 'inside' => '## some text with ##TOKEN## inside ##'));
     $this->tokenSurroundMixed = array('simple' => '##TOKEN##', 'inside' => '## some text with ##TOKEN## inside ##', 'nested' => array('simple' => '@@TOKEN@@', 'inside' => '@@ some text with @@TOKEN@@ inside @@'));
     $this->translator = array('pages' => array(array('id' => 'oneDog', 'label' => 'one dog', 'route' => 'app-one-dog'), array('id' => 'twoDogs', 'label' => 'two dogs', 'route' => 'app-two-dogs')));
     $this->translatorStrings = array('one dog' => 'ein Hund', 'two dogs' => 'zwei Hunde');
     $this->filter = array('simple' => 'some MixedCase VALue', 'nested' => array('simple' => 'OTHER mixed Case Value'));
     if (ArrayAdapter::hasCache()) {
         ArrayAdapter::clearCache();
         ArrayAdapter::removeCache();
     }
     $this->userConstants = array('simple' => 'SOME_USERLAND_CONSTANT', 'inside' => 'some text with SOME_USERLAND_CONSTANT inside', 'nested' => array('simple' => 'SOME_USERLAND_CONSTANT', 'inside' => 'some text with SOME_USERLAND_CONSTANT inside'));
     $this->phpConstants = array('phpVersion' => 'PHP_VERSION', 'phpVersionInside' => 'Current PHP version is: PHP_VERSION', 'nested' => array('phpVersion' => 'PHP_VERSION', 'phpVersionInside' => 'Current PHP version is: PHP_VERSION'));
 }
示例#5
0
 public function testLoadingFilesIntoCacheAfterwards()
 {
     $cache = Cache\Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => dirname(__FILE__) . '/_files/'));
     $this->assertFalse(Adapter\ArrayAdapter::hasCache());
     Adapter\ArrayAdapter::setCache($cache);
     $this->assertTrue(Adapter\ArrayAdapter::hasCache());
     $adapter = new Adapter\ArrayAdapter(dirname(__FILE__) . '/_files/translation_en.php', 'en');
     $cache = Adapter\ArrayAdapter::getCache();
     $this->assertTrue($cache instanceof Frontend\Core);
     $adapter->addTranslation(dirname(__FILE__) . '/_files/translation_en.php', 'ru', array('reload' => true));
     $test = $adapter->getMessages('all');
     $this->assertEquals(6, count($test['ru']));
 }
示例#6
0
    public function testLoadingFilesIntoCacheAfterwards()
    {
        $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0));

        $this->assertFalse(Adapter\ArrayAdapter::hasCache());
        Adapter\ArrayAdapter::setCache($cache);
        $this->assertTrue(Adapter\ArrayAdapter::hasCache());

        $adapter = new Adapter\ArrayAdapter(__DIR__ . '/_files/translation_en.php', 'en');
        $cache   = Adapter\ArrayAdapter::getCache();
        $this->assertTrue($cache instanceof CacheAdapter);

        $adapter->addTranslation(__DIR__ . '/_files/translation_en.php', 'ru', array('reload' => true));
        $test = $adapter->getMessages('all');
        $this->assertEquals(6, count($test['ru']));
    }
示例#7
0
 public function testLoadingFilesIntoCacheAfterwards()
 {
     $cache = CacheFactory::factory(array('adapter' => array('name' => 'Filesystem', 'options' => array('ttl' => 120, 'cache_dir' => $this->_cacheDir)), 'plugins' => array(array('name' => 'serializer', 'options' => array('serializer' => 'php_serialize')))));
     $this->assertFalse(Adapter\ArrayAdapter::hasCache());
     Adapter\ArrayAdapter::setCache($cache);
     $this->assertTrue(Adapter\ArrayAdapter::hasCache());
     $adapter = new Adapter\ArrayAdapter(__DIR__ . '/_files/translation_en.php', 'en');
     $cache = Adapter\ArrayAdapter::getCache();
     $this->assertTrue($cache instanceof CacheAdapter);
     $adapter->addTranslation(__DIR__ . '/_files/translation_en.php', 'ru', array('reload' => true));
     $test = $adapter->getMessages('all');
     $this->assertEquals(6, count($test['ru']));
 }