/** * Test if the `next` method moves to the next resource. */ public function testNextMoveForwardToNextResource() { $container = new TempResourceContainer(TempFileResource::TYPE); $container->create('php://temp/test1', 'test'); $container->create('php://temp/test2', 'test'); $container->rewind(); $container->next(); $this->assertSame('php://temp/test2', $container->key()); }
/** * 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); }