Beispiel #1
0
 public function testGeneration()
 {
     $dynamic = new Configuration();
     $dynamic->setImagine($this->getImagine());
     $dynamic->setColor($this->getColor());
     $dynamic->setImage(sprintf('%s/flags.png', $this->path));
     $dynamic->setStylesheet(sprintf('%s/flags.css', $this->path));
     $dynamic->setSelector(".flag.{{filename}}{background-position:{{x}}px {{y}}px}\n");
     $dynamic->getFinder()->name('*.png')->in(__DIR__ . '/Fixtures/flags')->sortByName();
     $fixed = new Configuration();
     $fixed->setImagine($this->getImagine());
     $fixed->setColor($this->getColor());
     $fixed->setImage(sprintf('%s/icons.png', $this->path));
     $fixed->setStylesheet(sprintf('%s/icons.css', $this->path));
     $fixed->setSelector(".icon.{{filename}}{background-position:{{x}}px {{y}}px}\n");
     $fixed->getFinder()->name('*.png')->in(__DIR__ . '/Fixtures/icons')->sortByName();
     $fixed->setWidth(16);
     $generator = new Generator();
     $generator->addConfiguration($dynamic);
     $generator->addConfiguration($fixed);
     $generator->addProcessor(new DynamicProcessor());
     $generator->addProcessor(new FixedProcessor());
     $generator->generate();
     $sprite = $dynamic->getImagine()->open($dynamic->getImage());
     $result = $dynamic->getImagine()->open(__DIR__ . '/Fixtures/results/flags.png');
     $this->assertImageEquals($sprite, $result);
     $this->assertFileEquals(__DIR__ . '/Fixtures/results/flags.css', $dynamic->getStylesheet());
     $sprite = $fixed->getImagine()->open($fixed->getImage());
     $result = $fixed->getImagine()->open(__DIR__ . '/Fixtures/results/icons.png');
     $this->assertImageEquals($result, $sprite);
     $this->assertFileEquals(__DIR__ . '/Fixtures/results/icons.css', $fixed->getStylesheet());
 }
 /**
  * Returns a Configuration instance.
  *
  * @param  InputInterface $input
  * @return Configuration
  */
 protected function getConfiguration(InputInterface $input)
 {
     $configuration = new Configuration();
     $configuration->setImagine($this->getImagine($input->getOption('driver')));
     $configuration->setOptions($input->getOption('options'));
     $configuration->getFinder()->name($input->getArgument('pattern'))->in($input->getArgument('source'));
     $configuration->setImage($input->getArgument('image'));
     $configuration->setColor(new Color($input->getOption('color'), $input->getOption('alpha')));
     $configuration->setStylesheet($input->getArgument('stylesheet'));
     $configuration->setSelector($input->getArgument('selector'));
     return $configuration;
 }
 public function testProcessing()
 {
     $config = new Configuration();
     $config->setImagine($this->getImagine());
     $config->setColor($this->getColor());
     $config->setImage(sprintf('%s/flags.png', $this->path));
     $config->setStylesheet(sprintf('%s/flags.css', $this->path));
     $config->setSelector(".flag.{{filename}}{background-position:{{x}}px {{y}}px}\n");
     $config->getFinder()->name('*.png')->in(__DIR__ . '/../Fixtures/flags')->sortByName();
     $processor = new DynamicProcessor();
     $processor->process($config);
     $sprite = $config->getImagine()->open($config->getImage());
     $result = $config->getImagine()->open(__DIR__ . '/../Fixtures/results/flags.png');
     $this->assertImageEquals($sprite, $result);
     $this->assertFileEquals(__DIR__ . '/../Fixtures/results/flags.css', $config->getStylesheet());
 }
Beispiel #4
0
 public function testProcessingWithResizing()
 {
     $config = new Configuration();
     $config->setImagine($this->getImagine());
     $config->setColor($this->getColor());
     $config->setImage(sprintf('%s/icons_resized.png', $this->path));
     $config->setStylesheet(sprintf('%s/icons_resized.css', $this->path));
     $config->setSelector(".icon.{{filename}}{background-position:{{x}}px {{y}}px}\n");
     $config->getFinder()->name('*.png')->in(__DIR__ . '/../Fixtures/icons')->sortByName();
     $config->setWidth(12);
     $processor = new FixedProcessor(array('resize' => true));
     $processor->process($config);
     $sprite = $config->getImagine()->open($config->getImage());
     $result = $config->getImagine()->open(__DIR__ . '/../Fixtures/results/icons_resized.png');
     $this->assertImageEquals($sprite, $result);
     $this->assertFileEquals(__DIR__ . '/../Fixtures/results/icons_resized.css', $config->getStylesheet());
 }