/** * Ensure that all fake data we use are valid FileStorage * data files. This should ensure, that fake backend and * other services depending on fake data will not encounter * broken data. */ public function testAllData() { $dir = FakeData::getDirectory(); $storage = new FileStorage(array("root_path" => $dir . '/')); $it = new RecursiveDirectoryIterator($dir); $nonrecursiveIt = new RecursiveIteratorIterator($it); $regexIt = new RegexIterator($nonrecursiveIt, '@\\.dat$@'); foreach ($regexIt as $file) { $this->assertTrue($file->isFile()); $key = $file->getPathname(); assert(StrUtil::startsWith($key, $dir)); // remove $dir from beginning of $key $key = substr($key, strlen($dir)); $key = preg_replace("@\\.dat\$@", "", $key); $data = $storage->read($key); $this->assertTrue(null !== $data); } }
public function setUp() { $this->response = new Response(); $this->requestParams = new MockInvocationParameters(); $time = mktime(0, 0, 0, 1, 8, 2010); $this->request = new Request($this->requestParams, $time); $this->context = new Context(); $this->context->setRequest($this->request); $this->context->setResponse($this->response); $temporary_storage = new MemoryStorage(); $permanent_storage = new FileStorage(array('root_path' => FakeData::getDirectory())); $this->storage = new TemporarilyModifiableStorage(array('permanent_storage' => $permanent_storage, 'temporary_storage' => $temporary_storage)); $this->context->setSessionStorage($this->storage); $factory = new StudiumFakeFactoryImpl($this->storage); $this->loginManager = $this->getMock('\\fajr\\LoginManager', array(), array(), '', false); $this->loginManager->expects($this->any())->method('isLoggedIn')->will($this->returnValue(true)); $this->router = $this->getMock('\\fajr\\Router', array(), array(), '', false); $this->controller = new StudiumController($factory, $time, $this->loginManager, $this->router); $this->storage->write('ais/aisApps', array(AIS2ApplicationEnum::ADMINISTRACIA_STUDIA)); }
public function __construct(sfSessionStorage $sessionStorage) { $options = array('permanent_storage' => new FileStorage(array('root_path' => FakeData::getDirectory())), 'temporary_storage' => $sessionStorage); $this->storage = new TemporarilyModifiableStorage($options); }