Esempio n. 1
0
 /**
  * Test if can store an annotation list.
  */
 public function testStoreAnnotationList()
 {
     /* @var \com\mohiva\common\lang\AnnotationReflector $class */
     $class = new ReflectionClass(self::TEST_CLASS);
     $docReflector = new ReflectionDocComment($class);
     $annotationList = $docReflector->getAnnotationList();
     $key = new HashKey(Hash::ALGO_SHA1, 'php://temp');
     $adapter = new ResourceAdapter(new TempResourceContainer(TempFileResource::TYPE));
     $container = new AnnotationContainer($adapter, $key);
     $container->store($class->getDocComment(), $annotationList);
     $this->assertTrue($adapter->exists($key));
 }
Esempio n. 2
0
 /**
  * Test if the `clean` method removes all expired resources.
  */
 public function testCleanRemovesExpiredResources()
 {
     $container = new TempResourceContainer(TempFileResource::TYPE);
     $container->create('php://temp/test1', 'A string')->getStat()->setModificationTime(time() - 5);
     $container->create('php://temp/test2', 'A string')->getStat()->setModificationTime(time() - 5);
     $container->create('php://temp/test3', 'A string')->getStat()->setModificationTime(time() - 5);
     $container->create('php://temp/test4', 'A string');
     $container->create('php://temp/test5', 'A string');
     $adapter = new ResourceAdapter($container);
     $adapter->setLifetime(1);
     $adapter->clean();
     $cnt = 0;
     $container->rewind();
     while ($container->valid()) {
         $container->next();
         $cnt++;
     }
     $this->assertSame(2, $cnt);
 }