/** * @test */ public function pluginShouldProvideForImage() { $filelib = new FileLibrary($this->getMockedStorageAdapter(), $this->getMockedBackendAdapter()); $filelib->addPlugin($this->plugin); $this->assertFalse($this->plugin->isApplicableTo(File::create(array('resource' => Resource::create(array('mimetype' => 'video/avi')))))); $this->assertTrue($this->plugin->isApplicableTo(File::create(array('resource' => Resource::create(array('mimetype' => 'image/png')))))); }
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; }
public function setUp() { $this->filelib = new FileLibrary(new FilesystemStorageAdapter(ROOT_TESTS . '/data/publisher/private'), new MemoryBackendAdapter()); $this->filelib->addPlugin(new OriginalVersionPlugin(), [], 'original'); }
/** * @test */ public function addPluginShouldFirePluginAddEventAndAddPluginAsSubscriber() { $ed = $this->getMockedEventDispatcher(); $filelib = new FileLibrary($this->getMockedStorageAdapter(), $this->getMockedBackendAdapter(), $ed); $plugin = $this->getMockForAbstractClass('Xi\\Filelib\\Plugin\\Plugin'); $ed->expects($this->once())->method('dispatch')->with($this->equalTo(Events::PLUGIN_AFTER_ADD), $this->isInstanceOf('Xi\\Filelib\\Event\\PluginEvent')); $ed->expects($this->once())->method('addSubscriber')->with($this->equalTo($plugin)); $filelib->addPlugin($plugin); }
/** * @test * @dataProvider provideMimetypes */ public function shouldProvideForVideo($expected, $mimetype) { $file = File::create(array('uuid' => Uuid::uuid4()->toString(), 'profile' => 'default', 'resource' => Resource::create(array('mimetype' => $mimetype)))); $filelib = new FileLibrary($this->getMockedStorageAdapter(), $this->getMockedBackendAdapter()); $filelib->addPlugin($this->plugin); $this->assertSame($expected, $this->plugin->isApplicableTo($file)); }