From ef7a0bce2a8281f91bff38dccaa5e84c0893c5ae Mon Sep 17 00:00:00 2001 From: Roel Sint Date: Sat, 24 Aug 2013 17:57:26 +0200 Subject: [PATCH] Add image test page and web test case --- .../Controller/PhpcrFileTestController.php | 8 +- .../Controller/PhpcrImageTestController.php | 172 ++++++++++++++++++ .../DataFixtures/Phpcr/LoadMediaData.php | 34 +++- Tests/Resources/Document/Content.php | 69 +++++++ Tests/Resources/app/AppKernel.php | 13 ++ .../Resources/app/Resources/data/cmf-logo.png | Bin 0 -> 18295 bytes .../app/Resources/data/testimage.png | Bin 0 -> 190 bytes .../app/Resources/views/index.html.twig | 1 + .../app/Resources/views/tests/file.html.twig | 2 +- .../app/Resources/views/tests/image.html.twig | 70 +++++++ Tests/Resources/app/config/cmf_media.yml | 6 + .../app/config/routing/cmf_media.yml | 25 ++- Tests/WebTest/TestApp/FileTest.php | 3 +- Tests/WebTest/TestApp/ImageTest.php | 95 ++++++++++ 14 files changed, 487 insertions(+), 11 deletions(-) create mode 100644 Tests/Resources/Controller/PhpcrImageTestController.php create mode 100644 Tests/Resources/Document/Content.php create mode 100644 Tests/Resources/app/Resources/data/cmf-logo.png create mode 100644 Tests/Resources/app/Resources/data/testimage.png create mode 100644 Tests/Resources/app/Resources/views/tests/image.html.twig create mode 100644 Tests/WebTest/TestApp/ImageTest.php diff --git a/Tests/Resources/Controller/PhpcrFileTestController.php b/Tests/Resources/Controller/PhpcrFileTestController.php index fe1e17e..cc3c852 100644 --- a/Tests/Resources/Controller/PhpcrFileTestController.php +++ b/Tests/Resources/Controller/PhpcrFileTestController.php @@ -16,7 +16,7 @@ public function getUploadForm() ; } - public function fileAction(Request $request) + public function indexAction(Request $request) { $fileClass = 'Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\File'; $dm = $this->get('doctrine_phpcr')->getManager('default'); @@ -26,9 +26,9 @@ public function fileAction(Request $request) $editorUploadForm = $this->getUploadForm(); return $this->render('::tests/file.html.twig', array( - 'upload_form' => $uploadForm->createView(), - 'editor_form' => $editorUploadForm->createView(), - 'files' => $files, + 'upload_form' => $uploadForm->createView(), + 'editor_form' => $editorUploadForm->createView(), + 'files' => $files, )); } diff --git a/Tests/Resources/Controller/PhpcrImageTestController.php b/Tests/Resources/Controller/PhpcrImageTestController.php new file mode 100644 index 0000000..c6003ec --- /dev/null +++ b/Tests/Resources/Controller/PhpcrImageTestController.php @@ -0,0 +1,172 @@ +container->get('form.factory')->createNamedBuilder(null, 'form') + ->add('image', 'file') + ->getForm() + ; + } + + protected function getContentForm(Content $contentObject = null, array $imageOptions = array()) + { + if (is_null($contentObject)) { + $contentObject = new Content(); + } + + return $this->createFormBuilder($contentObject) + ->add('name') + ->add('title') + ->add('image', 'cmf_media_image', array_merge(array('required' => false), $imageOptions)) + ->getForm() + ; + } + + protected function getUrlSafePath($object) + { + return ltrim($object->getId(), '/'); + } + + protected function mapUrlSafePathToId($path) + { + // The path is being the id + return PathHelper::absolutizePath($path, '/'); + } + + public function indexAction(Request $request) + { + $dm = $this->get('doctrine_phpcr')->getManager('default'); + + // get image(s) + $imageClass = 'Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image'; + $images = $dm->getRepository($imageClass)->findAll(); + + // get content with image object + $contentClass = 'Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Document\Content'; + $contentObject = $dm->getRepository($contentClass)->findOneBy(array()); + + $uploadForm = $this->getUploadForm(); + $editorUploadForm = $this->getUploadForm(); + + // Form - content object with image embedded + $newContentForm = $this->getContentForm(null, array('required' => true)); + $contentForm = $this->getContentForm($contentObject, array('imagine_filter' => false)); + $contentFormImagine = $this->getContentForm($contentObject); + + // action url + if ($contentObject) { + $contentFormEditAction = $this->generateUrl('phpcr_image_test_content_edit', array( + 'path' => $this->getUrlSafePath($contentObject), + )); + } else { + $contentFormEditAction = false; + } + + return $this->render('::tests/image.html.twig', array( + 'upload_form' => $uploadForm->createView(), + 'editor_form' => $editorUploadForm->createView(), + 'content_form_new' => $newContentForm->createView(), + 'content_form' => $contentForm->createView(), + 'content_form_imagine' => $contentFormImagine->createView(), + 'content_form_edit_action' => $contentFormEditAction, + 'images' => $images, + )); + } + + public function uploadAction(Request $request) + { + $form = $this->getUploadForm(); + + if ($request->isMethod('POST')) { + $form->bind($request); + + if ($form->isValid()) { + /** @var UploadFileHelper $uploadFileHelper */ + $uploadImageHelper = $this->get('cmf_media.upload_image_helper'); + + $uploadedFile = $request->files->get('image'); + + $image = $uploadImageHelper->handleUploadedFile($uploadedFile); + + // persist + $dm = $this->get('doctrine_phpcr')->getManager('default'); + $dm->persist($image); + $dm->flush(); + } + } + + return $this->redirect($this->generateUrl('phpcr_image_test')); + } + + public function newAction(Request $request) + { + $dm = $this->get('doctrine_phpcr')->getManager('default'); + $contentRoot = $dm->find(null, '/test/content'); + + if (!$contentRoot) { + $root = $dm->find(null, '/test'); + $contentRoot = new Generic(); + $contentRoot->setNodename('content'); + $contentRoot->setParent($root); + $dm->persist($contentRoot); + } + + $contentObject = new Content(); + $contentObject->setParent($contentRoot); + + $form = $this->getContentForm($contentObject); + + if ($request->isMethod('POST')) { + $form->bind($request); + + if ($form->isValid()) { + // persist + $dm = $this->get('doctrine_phpcr')->getManager('default'); + $dm->persist($contentObject); + $dm->flush(); + } + } + + return $this->redirect($this->generateUrl('phpcr_image_test')); + } + + public function editAction(Request $request, $path) + { + $dm = $this->get('doctrine_phpcr')->getManager('default'); + + $contentObject = $dm->find(null, $this->mapUrlSafePathToId($path)); + + if (!$contentObject || !$contentObject instanceof Content) { + throw new NotFoundHttpException(sprintf( + 'Object with identifier %s cannot be resolved to a valid instance of Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Document\Content', + $path + )); + } + + $form = $this->getContentForm($contentObject); + + if ($request->isMethod('POST')) { + $form->bind($request); + + if ($form->isValid()) { + // persist + $dm = $this->get('doctrine_phpcr')->getManager('default'); + $dm->persist($contentObject); + $dm->flush(); + } + } + + return $this->redirect($this->generateUrl('phpcr_image_test')); + } +} diff --git a/Tests/Resources/DataFixtures/Phpcr/LoadMediaData.php b/Tests/Resources/DataFixtures/Phpcr/LoadMediaData.php index e798966..f803f52 100644 --- a/Tests/Resources/DataFixtures/Phpcr/LoadMediaData.php +++ b/Tests/Resources/DataFixtures/Phpcr/LoadMediaData.php @@ -7,6 +7,8 @@ use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ODM\PHPCR\Document\Generic; use Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\File; +use Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image; +use Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Document\Content; class LoadMediaData implements FixtureInterface, DependentFixtureInterface { @@ -19,12 +21,22 @@ public function getDependencies() public function load(ObjectManager $manager) { + $testDataDir = realpath(__DIR__ . '/../../app/Resources/data'); + $root = $manager->find(null, '/test'); - $mediaRoot = new Generic; + + // media root + $mediaRoot = new Generic(); $mediaRoot->setNodename('media'); $mediaRoot->setParent($root); $manager->persist($mediaRoot); + // content root + $contentRoot = new Generic(); + $contentRoot->setNodename('content'); + $contentRoot->setParent($root); + $manager->persist($contentRoot); + // File $file = new File(); $file->setParent($mediaRoot); @@ -33,6 +45,26 @@ public function load(ObjectManager $manager) $file->setContentType('text/plain'); $manager->persist($file); + // Image + $image = new Image(); + $image->setParent($mediaRoot); + $image->setName('cmf-logo.png'); + $image->setFileContentFromFilesystem($testDataDir .'/cmf-logo.png'); + $manager->persist($image); + + // Content + $content = new Content(); + $content->setParent($contentRoot); + $content->setName('content-with-image'); + $content->setTitle('Content document with image embedded'); + + $contentImage = new Image(); + $contentImage->setName('cmf-logo.png'); + $contentImage->setFileContentFromFilesystem($testDataDir .'/cmf-logo.png'); + + $content->setImage($contentImage); + $manager->persist($content); + $manager->flush(); } } diff --git a/Tests/Resources/Document/Content.php b/Tests/Resources/Document/Content.php new file mode 100644 index 0000000..96db7e0 --- /dev/null +++ b/Tests/Resources/Document/Content.php @@ -0,0 +1,69 @@ +image) { + // existing image, only update content + // TODO: https://github.com/doctrine/phpcr-odm/pull/262 + $this->image->copyContentFromFile($image); + } elseif ($image instanceof ImageInterface) { + $this->image = $image; + } else { + $this->image = new Image(); + $this->image->copyContentFromFile($image); + } + } + + /** + * Get image + * + * @return Image + */ + public function getImage() + { + return $this->image; + } +} \ No newline at end of file diff --git a/Tests/Resources/app/AppKernel.php b/Tests/Resources/app/AppKernel.php index 3fea41f..103315b 100644 --- a/Tests/Resources/app/AppKernel.php +++ b/Tests/Resources/app/AppKernel.php @@ -23,4 +23,17 @@ public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(__DIR__.'/config/config.php'); } + + /** + * Returns the kernel parameters. + * + * @return array An array of kernel parameters + */ + protected function getKernelParameters() + { + return array_merge( + parent::getKernelParameters(), + array('kernel.cmf_test_web_dir' => CMF_TEST_ROOT_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'web') + ); + } } diff --git a/Tests/Resources/app/Resources/data/cmf-logo.png b/Tests/Resources/app/Resources/data/cmf-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..074313b84bbe2ceecdcb24f761f763aa07a01327 GIT binary patch literal 18295 zcmZ_0Wmp_t(*_6$1WRzY;O-jSJ-EBO1$TIYySoN=cZPxB7F-6`;O-9FdB5GC3l}iV zHFVRb>r~Y(H4#b*QeP195uu=s zsM_dv#6MvYPbD%1h)8CQcd&Ub3Si zAra0}|99M}DKJ89e*VvGc1s#2+We}f=-E=F;mOI;wzl-ED`y*9+w$5<7mQqkT51xK z|28*`$jHbeVqz#+X(Q4PtjNg8BO+s|czJcQ%>Q?^A8!b?H8ru>*@Vst*_*=&84U~%1ZHJF!3Ma;Ym9=glfCVMG#@ogN17$NvWxlc{i?XY;4kUa^#$hF-1ib_Jf>O zQ@^(05S_ZNE)WqB7u!wYKpy8NleyrNjn+wd3j>q`5j)GEV^Ga`TR1DlxAZ?fL3kWi zEMlRbEe`7PVPIfv8f*WzL|bk|3c36v+{chc>m8~VbNj-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KrAj{LIG?IN%i$5*8F444hhTp8cmq0N7gx zc11b)xs{c)ChfRkk@WacM}NOMuoHCUO32#MUa)^&#I;-(FHpn}G=QrW&!`DI9z596(vq>v3vyD+L&14qjTbIN25eCTo%#XfKFlPZ5!>*e az5V8|nVuRi<$y=zFnGH9xvXPhpcr

About

This test application is built into the MediaBundle. You can easily run diff --git a/Tests/Resources/app/Resources/views/tests/file.html.twig b/Tests/Resources/app/Resources/views/tests/file.html.twig index 01f39fe..e0e1c5b 100644 --- a/Tests/Resources/app/Resources/views/tests/file.html.twig +++ b/Tests/Resources/app/Resources/views/tests/file.html.twig @@ -25,7 +25,7 @@ {% else %}

{% endif %} diff --git a/Tests/Resources/app/Resources/views/tests/image.html.twig b/Tests/Resources/app/Resources/views/tests/image.html.twig new file mode 100644 index 0000000..f420dce --- /dev/null +++ b/Tests/Resources/app/Resources/views/tests/image.html.twig @@ -0,0 +1,70 @@ +{% extends "::layout.html.twig" %} +{% block content %} +

Upload image

+ +

Standard upload

+

The upload is handled by your own controller action. The UploadFileHelper is used to handle the upload and creates a + FileInterface object, writing the object to storage has to be implemented by yourself.

+
+ {{ form_widget(upload_form) }} + + +
+ +

Web editor upload (default)

+

The upload is completely handled by the ImageController::uploadAction. The UploadFileHelper will process the upload, + writes the created FileInterface object to storage and returns a response that depends on the editor defined in the + request.

+
+ {{ form_widget(editor_form) }} + + +
+ +

Content object with an image embedded (new)

+

This will use the cmf_media_image form type.

+
+ {{ form_widget(content_form_new) }} + + +
+ + {% if content_form_edit_action %} +

Content object with an image embedded (edit)

+

This will use the cmf_media_image form type that will show a preview of the uploaded image.

+
+ {{ form_widget(content_form) }} + + +
+ +

Content object with an image embedded (edit) - using LiipImagineBundle for the image preview

+

This will use the cmf_media_image form type that will show a preview of the uploaded image.

+
+ {{ form_widget(content_form_imagine) }} + + +
+ {% endif %} + +

Display image(s)

+ {% if images is empty %} +

No images found, upload an image first.

+ {% else %} +
    + {% for image in images %} +
  • +

    {{ image.name }} (id: {{ image.id }})

    +

    Using the ImageController::displayAction: + {{ '{{' }} cmf_media_display_url(image) {{ '}}' }}

    +

    {{ image.description }}

    + +

    Using LiipImagineBundle:
    + {{ '{{' }} cmf_media_display_url(image, { imagine_filter: 'image_upload_thumbnail' }) {{ '}}' }} + or {{ '{{' }} image.id | imagine_filter('image_upload_thumbnail') {{ '}}' }}

    +

    {{ image.description }}

    +
  • + {% endfor %} +
+ {% endif %} +{% endblock %} diff --git a/Tests/Resources/app/config/cmf_media.yml b/Tests/Resources/app/config/cmf_media.yml index 6482d85..e42ab7c 100644 --- a/Tests/Resources/app/config/cmf_media.yml +++ b/Tests/Resources/app/config/cmf_media.yml @@ -1,3 +1,8 @@ +twig: + form: + resources: + - 'CmfMediaBundle:Form:fields.html.twig' + cmf_media: persistence: phpcr: @@ -8,6 +13,7 @@ cmf_media: # to a specific format. (ie a controller render the file) # more information can be found here : https://github.com/liip/LiipImagineBundle liip_imagine: + web_root: %kernel.cmf_test_web_dir% filter_sets: # define the filter to be used with the image preview image_upload_thumbnail: diff --git a/Tests/Resources/app/config/routing/cmf_media.yml b/Tests/Resources/app/config/routing/cmf_media.yml index df944ab..cf2a02b 100644 --- a/Tests/Resources/app/config/routing/cmf_media.yml +++ b/Tests/Resources/app/config/routing/cmf_media.yml @@ -6,17 +6,34 @@ test_index: phpcr_file_test: pattern: /phpcr/file-test defaults: - _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrFileTestController::fileAction + _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrFileTestController::indexAction phpcr_file_test_upload: pattern: /phpcr/file-test/upload defaults: _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrFileTestController::uploadAction -phpcr_file_test_upload_editor: - pattern: /phpcr/file-test/upload/editor +phpcr_image_test: + pattern: /phpcr/image-test defaults: - _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrFileTestController::editorUploadAction + _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrImageTestController::indexAction + +phpcr_image_test_upload: + pattern: /phpcr/image-test/upload + defaults: + _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrImageTestController::uploadAction + +phpcr_image_test_content_new: + pattern: /phpcr/image-test/content/new + defaults: + _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrImageTestController::newAction + +phpcr_image_test_content_edit: + pattern: /phpcr/image-test/content/edit/{path} + defaults: + _controller: Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\Controller\PhpcrImageTestController::editAction + requirements: + path: .* cmf_media_file: resource: "@CmfMediaBundle/Resources/config/routing/file.xml" diff --git a/Tests/WebTest/TestApp/FileTest.php b/Tests/WebTest/TestApp/FileTest.php index 9981864..877c959 100644 --- a/Tests/WebTest/TestApp/FileTest.php +++ b/Tests/WebTest/TestApp/FileTest.php @@ -24,7 +24,8 @@ public function testPage() $resp = $client->getResponse(); $this->assertEquals(200, $resp->getStatusCode()); - $this->assertGreaterThanOrEqual(1, $crawler->filter('.downloads li a')->count()); + // 1 file and 1 image + $this->assertGreaterThanOrEqual(2, $crawler->filter('.downloads li a')->count()); } public function testUpload() diff --git a/Tests/WebTest/TestApp/ImageTest.php b/Tests/WebTest/TestApp/ImageTest.php new file mode 100644 index 0000000..bc79cd0 --- /dev/null +++ b/Tests/WebTest/TestApp/ImageTest.php @@ -0,0 +1,95 @@ +db('PHPCR')->loadFixtures(array( + 'Symfony\Cmf\Bundle\MediaBundle\Tests\Resources\DataFixtures\Phpcr\LoadMediaData', + )); + $this->testDataDir = $this->getContainer()->get('kernel')->getRootDir() . '/Resources/data'; + } + + public function testPage() + { + $client = $this->createClient(); + $crawler = $client->request('get', $this->getContainer()->get('router')->generate('phpcr_image_test')); + $resp = $client->getResponse(); + + $this->assertEquals(200, $resp->getStatusCode()); + + // image(s) display + $this->assertGreaterThanOrEqual(4, $crawler->filter('.images li img')->count()); + + // cmf_media_image form tests + $this->assertEquals(0, $crawler->filter('.cmf_media_image.new img')->count()); + $this->assertEquals(1, $crawler->filter('.cmf_media_image.edit.default img')->count()); + $this->assertEquals(1, $crawler->filter('.cmf_media_image.edit.imagine img')->count()); + + // cmf_media_display_url + $defaultImageLink = $crawler->filter('.images li img.default')->first()->attr('src'); + $client->request('get', $defaultImageLink); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'default image test'); + + // imagine_filter + $this->getContainer()->get('liip_imagine.cache.clearer')->clear('image_upload_thumb'); + $imagineImageLink = $crawler->filter('.images li img.imagine')->first()->attr('src'); + $client->request('get', $imagineImageLink); + $this->assertTrue($client->getResponse()->isSuccessful(), 'imagine image test'); + } + + public function testUpload() + { + $client = $this->createClient(); + $crawler = $client->request('get', $this->getContainer()->get('router')->generate('phpcr_image_test')); + $cntImagesLinks = $crawler->filter('.images li img')->count(); + + $buttonCrawlerNode = $crawler->filter('form.standard')->selectButton('submit'); + $form = $buttonCrawlerNode->form(); + $form['image']->upload($this->testDataDir . '/testimage.png'); + + $client->submit($form); + $crawler = $client->followRedirect(); + $resp = $client->getResponse(); + + $this->assertEquals(200, $resp->getStatusCode()); + $this->assertEquals($cntImagesLinks + 2, $crawler->filter('.images li img')->count()); + } + + public function testEditorUpload() + { + $client = $this->createClient(array(), array( + 'PHP_AUTH_USER' => 'admin', + 'PHP_AUTH_PW' => 'adminpass', + )); + $crawler = $client->request('get', $this->getContainer()->get('router')->generate('phpcr_image_test')); + $cntImagesLinks = $crawler->filter('.images li img')->count(); + + $buttonCrawlerNode = $crawler->filter('form.editor.default')->selectButton('submit'); + $form = $buttonCrawlerNode->form(); + $form['image']->upload($this->testDataDir . '/testimage.png'); + + $client->submit($form); + $crawler = $client->followRedirect(); + /** @var Response $resp */ + $resp = $client->getResponse(); + + $this->assertEquals(200, $resp->getStatusCode()); + $this->assertNotEmpty($resp->getContent()); + $this->assertEquals('image/png', $resp->headers->get('Content-Type')); // check that the response is an image + + $crawler = $client->request('get', $this->getContainer()->get('router')->generate('phpcr_image_test')); + $resp = $client->getResponse(); + $this->assertEquals(200, $resp->getStatusCode()); + $this->assertEquals($cntImagesLinks + 2, $crawler->filter('.images li img')->count()); + } +}