/**
  * @test
  */
 public function shouldBeConfigurableWithAClosure()
 {
     $file1 = $this->getMockedFile();
     $file2 = $this->getMockedFile();
     $func = function (File $file) use($file1, $file2) {
         if ($file === $file1) {
             return true;
         }
         return false;
     };
     $acl = new SimpleAuthorizationAdapter();
     $acl->setFileReadableByAnonymous($func);
     $this->assertTrue($acl->isFileReadableByAnonymous($file1));
     $this->assertFalse($acl->isFileReadableByAnonymous($file2));
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     /*
     if (!extension_loaded('mongo')) {
         $this->markTestSkipped('MongoDB extension is not loaded.');
     }
     
     try {
         $mongoClient = new MongoClient(MONGO_DNS);
     } catch (MongoConnectionException $e) {
         return $this->markTestSkipped('Can not connect to MongoDB.');
     }
     
     
     $this->mongo = $mongoClient->selectDb('filelib_tests');
     */
     $stopwatch = new Stopwatch();
     $ed = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
     $this->conn = DriverManager::getConnection(array('driver' => 'pdo_' . PDO_DRIVER, 'dbname' => PDO_DBNAME, 'user' => PDO_USERNAME, 'password' => PDO_PASSWORD, 'host' => PDO_HOST));
     $filelib = new FileLibrary(new FilesystemStorageAdapter(ROOT_TESTS . '/data/files'), new DoctrineDbalBackendAdapter($this->conn), $ed);
     $memcached = new Memcached();
     $memcached->addServer('localhost', 11211);
     $this->memcached = $memcached;
     $this->memcached->flush();
     $filelib->addPlugin(new RandomizeNamePlugin());
     $authorizationAdapter = new SimpleAuthorizationAdapter();
     $authorizationPlugin = new AuthorizationPlugin($authorizationAdapter);
     $filelib->addPlugin($authorizationPlugin, array('default'));
     $authorizationAdapter->setFolderWritable(true)->setFileReadableByAnonymous(true)->setFileReadable(true);
     $this->authorizationAdapter = $authorizationAdapter;
     $publisher = new Publisher(new SymlinkFilesystemPublisherAdapter(ROOT_TESTS . '/data/publisher/public', '600', '700', 'files'), new BeautifurlLinker());
     $publisher->attachTo($filelib);
     $this->publisher = $publisher;
     $originalPlugin = new OriginalVersionPlugin('original');
     $filelib->addPlugin($originalPlugin, array('default'));
     $versionPlugin = new VersionPlugin(array('cinemascope' => array(array(array('setImageCompression', Imagick::COMPRESSION_JPEG), array('setImageFormat', 'jpg'), array('setImageCompressionQuality', 50), array('cropThumbnailImage', array(800, 200)), array('sepiaToneImage', 90), 'Xi\\Filelib\\Plugin\\Image\\Command\\WatermarkCommand' => array(ROOT_TESTS . '/data/watermark.png', 'se', 10))), 'croppo' => array(array(array('setImageCompression', Imagick::COMPRESSION_JPEG), array('setImageFormat', 'jpg'), array('setImageCompressionQuality', 80), array('cropThumbnailImage', array(400, 400)), 'Xi\\Filelib\\Plugin\\Image\\Command\\WatermarkCommand' => array(ROOT_TESTS . '/data/watermark.png', 'se', 10)))));
     $filelib->addPlugin($versionPlugin, array('default'));
     $this->filelib = $filelib;
 }