/**
  * Check that an image was uploaded and can be viewed on the page.
  *
  * @Then /^(?:|I )should see the thumbnail$/
  */
 public function iShouldSeeTheThumbnail()
 {
     $page = $this->getWorkingElement();
     $thumb = false;
     foreach (array('media-thumbnail', 'image-preview') as $classname) {
         if ($thumb) {
             break;
         }
         $thumb = $page->find('css', ".{$classname} img");
     }
     if (!$thumb) {
         throw new \Exception('An expected image tag was not found.');
     }
     $file = explode('?', $thumb->getAttribute('src'));
     $file = reset($file);
     $curl = new CurlService();
     list(, $info) = $curl->execute('GET', $file);
     if (empty($info) || strpos($info['content_type'], 'image/') === false) {
         throw new FileNotFoundException(sprintf('%s did not return an image', $file));
     }
 }
Exemplo n.º 2
0
 /**
  * Check that an image was uploaded and can be viewed on the page.
  *
  * @throws \Exception
  * @throws FileNotFoundException
  *
  * @Then /^(?:|I )should see the thumbnail$/
  */
 public function shouldSeeThumbnail()
 {
     $thumb = false;
     foreach (['.upload-preview', '.media-thumbnail img', '.image-preview img'] as $selector) {
         if ($thumb) {
             break;
         }
         $thumb = $this->findByCss($selector);
     }
     if (null === $thumb) {
         throw new \Exception('An expected image tag was not found.');
     }
     $file = explode('?', $thumb->getAttribute('src'));
     $file = reset($file);
     $curl = new CurlService();
     list(, $info) = $curl->execute('GET', $file);
     if (empty($info) || strpos($info['content_type'], 'image/') === false) {
         throw new FileNotFoundException(sprintf('%s did not return an image', $file));
     }
 }