From fa5da95bf160c8658d956a8390cc656a1b212730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 8 Oct 2015 17:21:48 +0200 Subject: [PATCH] first impl on test on TranslatableActivityReasonType Currently skipped due to the amount of work required and the expectance refs #651 --- .../Type/TranslatableActivityReasonTest.php | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Tests/Form/Type/TranslatableActivityReasonTest.php diff --git a/Tests/Form/Type/TranslatableActivityReasonTest.php b/Tests/Form/Type/TranslatableActivityReasonTest.php new file mode 100644 index 000000000..59812009e --- /dev/null +++ b/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -0,0 +1,110 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Tests\Form\Type; + +use Symfony\Component\Form\Test\TypeTestCase; +use Chill\ActivityBundle\Form\Type\TranslatableActivityReason; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Component\Form\PreloadedExtension; + +/** + * Test translatableActivityReason + * + * @author Julien Fastré + * @author Champs Libres + */ +class TranslatableActivityReasonTest extends TypeTestCase +{ + /** + * + * @var Prophecy\Prophet + */ + private static $prophet; + + public function setUp() + { + parent::setUp(); + + + } + + protected function getExtensions() + { + $entityType = $this->getEntityType(); + + return array(new PreloadedExtension(array( + 'entity' => $entityType + ), array())); + } + + + public function testSimple() + { + $translatableActivityReasonType = new TranslatableActivityReason( + $this->getTranslatableStringHelper() + ); + + $this->markTestSkipped("See issue 651"); + } + + /** + * + * @param string $locale + * @param string $fallbackLocale + * @return TranslatableStringHelper + */ + protected function getTranslatableStringHelper($locale = 'en', + $fallbackLocale = 'en') + { + $prophet = new \Prophecy\Prophet; + $requestStack = $prophet->prophesize(); + $request = $prophet->prophesize(); + $translator = $prophet->prophesize(); + + $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->getLocale()->willReturn($fallbackLocale); + + $requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack->getCurrentRequest()->will(function () use ($request) { + return $request; + }); + + $translator->willExtend('Symfony\Component\Translation\Translator'); + $translator->getFallbackLocales()->willReturn($locale); + + return new TranslatableStringHelper($requestStack->reveal(), + $translator->reveal()); + + } + + /** + * + * @return \Symfony\Bridge\Doctrine\Form\Type\EntityType + */ + protected function getEntityType() + { + $managerRegistry = (new \Prophecy\Prophet())->prophesize(); + + $managerRegistry->willImplement('Doctrine\Common\Persistence\ManagerRegistry'); + + return new \Symfony\Bridge\Doctrine\Form\Type\EntityType($managerRegistry->reveal()); + } +}