Esempio n. 1
0
 public function setup()
 {
     $this->fs = new Filesystem(new Local(__DIR__ . '/images'));
     $this->logoJpg = $this->fs->getImage('generic-logo.jpg');
     $this->landscapeImage = $this->fs->getImage('samples/sample1.jpg');
     $this->portraitImage = $this->fs->getImage('samples/sample2.jpg');
 }
Esempio n. 2
0
 /**
  * @dataProvider getAcceptData
  */
 public function testAccept($mode, array $expected)
 {
     $filesystem = $this->getMock(Filesystem::class, ['getTimestamp'], [$this->filesystem->getAdapter()]);
     $filesystem->method('getTimestamp')->willReturnMap([['fixtures/js/script.js', 1], ['fixtures/css/reset.css', 9], ['fixtures', 2], ['fixtures/css/old/old_style.css', 8], ['fixtures/base.css', 4], ['fixtures/css/style.css', 7], ['fixtures/css/old', 5], ['fixtures/js', 6], ['fixtures/css', 3]]);
     $iterator = new \ArrayIterator([new File($filesystem, 'fixtures/js/script.js'), new File($filesystem, 'fixtures/css/reset.css'), new File($filesystem, 'fixtures'), new File($filesystem, 'fixtures/css/old/old_style.css'), new File($filesystem, 'fixtures/base.css'), new File($filesystem, 'fixtures/css/style.css'), new File($filesystem, 'fixtures/css/old'), new File($filesystem, 'fixtures/js'), new File($filesystem, 'fixtures/css')]);
     $iterator = new SortableIterator($iterator, $mode);
     $this->assertOrderedIterator($expected, $iterator);
 }
Esempio n. 3
0
 public function setup()
 {
     $samples = new Filesystem\Filesystem(new Local(__DIR__ . '/images/samples'));
     $subdir = new Filesystem\Filesystem(new Local(__DIR__ . '/images/subdir'));
     $images = new Filesystem\Filesystem(new Local(__DIR__ . '/images'));
     $filesystems = ['samples' => $samples, 'subdir' => $subdir, 'images' => $images];
     $this->fs = new Filesystem\Manager($filesystems);
     $default = $images->getImage('samples/sample1.jpg');
     $this->finder = new Finder($this->fs, array_keys($filesystems), $default);
 }
Esempio n. 4
0
 public function testExifOrientation()
 {
     $images = array('1-top-left', '2-top-right', '3-bottom-right', '4-bottom-left', '5-left-top', '6-right-top', '7-right-bottom', '8-left-bottom');
     $expected = new Dimensions(400, 200);
     foreach ($images as $name) {
         $image = $this->fs->getImage('exif-orientation/' . $name . '.jpg');
         $resource = ImageResource::createFromString($image->read());
         $this->assertDimensions($expected, $resource->getDimensions());
         $color = $resource->getColorAt(new Point());
         $this->assertTrue($color->getRed() > 250 && $color->getGreen() < 10 && $color->getBlue() < 5, 'Wrong orientation');
     }
 }
Esempio n. 5
0
 public function testJsonSerialize()
 {
     $file = $this->filesystem->getFile('fixtures/images/1-top-left.jpg')->read();
     $expected = Image\Info::createFromString($file);
     $actual = Image\Info::createFromJson(json_decode(json_encode($expected), true));
     $this->assertEquals($expected->getDimensions(), $actual->getDimensions());
     $this->assertSame($expected->getType(), $actual->getType());
     $this->assertSame($expected->getBits(), $actual->getBits());
     $this->assertSame($expected->getChannels(), $actual->getChannels());
     $this->assertSame($expected->getMime(), $actual->getMime());
     $this->assertEquals($expected->getExif()->getData(), $actual->getExif()->getData());
 }
Esempio n. 6
0
 public function register(Application $app)
 {
     // These can be called early
     $app['filesystem.config'] = $app->share(function ($app) {
         $fs = new Filesystem(new Local($app['resources']->getPath('config')));
         $fs->setMountPoint('config');
         return $fs;
     });
     $app['filesystem.cache'] = $app->share(function ($app) {
         $fs = new Filesystem(new Local($app['resources']->getPath('cache')));
         $fs->setMountPoint('cache');
         return $fs;
     });
     $app['filesystem.themes'] = $app->share(function ($app) {
         $fs = new Filesystem(new Local($app['resources']->getPath('themebase')));
         $fs->setMountPoint('themes');
         return $fs;
     });
     // Calling this before boot … all bets are off … and if Bolt breaks, you get to keep both pieces!
     // @TODO :fire: this when the new configuration loading lands
     $app['filesystem.theme'] = $app->share(function ($app) {
         $fs = new Filesystem(new Local($app['resources']->getPath('themebase') . '/' . $app['config']->get('general/theme')));
         $fs->setMountPoint('theme');
         return $fs;
     });
     // Don't call this until boot.
     $app['filesystem'] = $app->share(function ($app) {
         $manager = new Manager(['bolt' => new Filesystem(new Local(__DIR__ . '/../../')), 'root' => new Filesystem(new Local($app['resources']->getPath('root'))), 'web' => new Filesystem(new Local($app['resources']->getPath('web'))), 'files' => new Filesystem(new Local($app['resources']->getPath('files'))), 'config' => $app['filesystem.config'], 'themes' => $app['filesystem.themes'], 'theme' => $app['filesystem.theme'], 'extensions' => new Filesystem(new Local($app['resources']->getPath('extensions'))), 'cache' => $app['filesystem.cache'], 'app' => new Filesystem(new Local($app['resources']->getPath('app'))), 'view' => new Filesystem(new Local($app['resources']->getPath('view'))), 'default' => new Filesystem(new Local($app['resources']->getPath('files')))], [new Plugin\HasUrl(), new Plugin\Parents(), new Plugin\ToJs(), new Plugin\Authorized($app['filepermissions']), new Plugin\ThumbnailUrl($app['url_generator.lazy'])]);
         return $manager;
     });
     $app['filesystem.plugin.url'] = function () use($app) {
         return new Plugin\AssetUrl($app['asset.packages']);
     };
     $app['filesystem.matcher'] = $app->share(function ($app) {
         return new Matcher($app['filesystem'], $app['filesystem.matcher.mount_points']);
     });
     $app['filesystem.matcher.mount_points'] = ['files', 'themes', 'theme'];
 }