From df7e66c067aeb26db33402eac5c643e40b541ca1 Mon Sep 17 00:00:00 2001 From: Sadikov Vladimir Date: Tue, 19 Dec 2017 22:02:02 +0200 Subject: [PATCH] step 5: fix tests --- tests/Fixtures/Entity/MediaLocalize.php | 2 +- tests/Fixtures/Entity/Product.php | 2 +- tests/Fixtures/Entity/ProductTranslation.php | 2 +- tests/Fixtures/Form/MediaLocalizeType.php | 4 +-- .../TranslationsFormsTypeAdvancedTest.php | 10 +++---- .../Type/TranslationsFormsTypeSimpleTest.php | 12 ++++---- .../Type/TranslationsTypeAdvancedTest.php | 10 +++---- .../Form/Type/TranslationsTypeSimpleTest.php | 10 +++---- tests/Form/TypeTestCase.php | 28 +++++++++---------- tests/Locale/DefaultProviderTest.php | 15 +++++----- 10 files changed, 48 insertions(+), 47 deletions(-) diff --git a/tests/Fixtures/Entity/MediaLocalize.php b/tests/Fixtures/Entity/MediaLocalize.php index e211537..b690262 100644 --- a/tests/Fixtures/Entity/MediaLocalize.php +++ b/tests/Fixtures/Entity/MediaLocalize.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Fixtures\Entity; +namespace Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity; use Doctrine\ORM\Mapping as ORM; diff --git a/tests/Fixtures/Entity/Product.php b/tests/Fixtures/Entity/Product.php index 32993eb..201695f 100644 --- a/tests/Fixtures/Entity/Product.php +++ b/tests/Fixtures/Entity/Product.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Fixtures\Entity; +namespace Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity; use Doctrine\ORM\Mapping as ORM; diff --git a/tests/Fixtures/Entity/ProductTranslation.php b/tests/Fixtures/Entity/ProductTranslation.php index e16c02d..5096bf9 100644 --- a/tests/Fixtures/Entity/ProductTranslation.php +++ b/tests/Fixtures/Entity/ProductTranslation.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Fixtures\Entity; +namespace Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity; use Doctrine\ORM\Mapping as ORM; diff --git a/tests/Fixtures/Form/MediaLocalizeType.php b/tests/Fixtures/Form/MediaLocalizeType.php index 226d9f4..38fd3f7 100644 --- a/tests/Fixtures/Form/MediaLocalizeType.php +++ b/tests/Fixtures/Form/MediaLocalizeType.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Fixtures\Form; +namespace Koff\Bundle\I18nFormBundle\Tests\Fixtures\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -28,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'A2lix\TranslationFormBundle\Tests\Fixtures\Entity\MediaLocalize', + 'data_class' => 'Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\MediaLocalize', ]); } } diff --git a/tests/Form/Type/TranslationsFormsTypeAdvancedTest.php b/tests/Form/Type/TranslationsFormsTypeAdvancedTest.php index f38022e..0bdb20d 100644 --- a/tests/Form/Type/TranslationsFormsTypeAdvancedTest.php +++ b/tests/Form/Type/TranslationsFormsTypeAdvancedTest.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Form\Type; +namespace Koff\Bundle\I18nFormBundle\Tests\Form\Type; -use A2lix\TranslationFormBundle\Form\Type\TranslationsFormsType; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\Product; -use A2lix\TranslationFormBundle\Tests\Fixtures\Form\MediaLocalizeType; -use A2lix\TranslationFormBundle\Tests\Form\TypeTestCase; +use Koff\Bundle\I18nFormBundle\Form\Type\TranslationsFormsType; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\Product; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Form\MediaLocalizeType; +use Koff\Bundle\I18nFormBundle\Tests\Form\TypeTestCase; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\PreloadedExtension; diff --git a/tests/Form/Type/TranslationsFormsTypeSimpleTest.php b/tests/Form/Type/TranslationsFormsTypeSimpleTest.php index 94c99a4..39d8cd9 100644 --- a/tests/Form/Type/TranslationsFormsTypeSimpleTest.php +++ b/tests/Form/Type/TranslationsFormsTypeSimpleTest.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Form\Type; +namespace Koff\Bundle\I18nFormBundle\Tests\Form\Type; -use A2lix\TranslationFormBundle\Form\Type\TranslationsFormsType; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\MediaLocalize; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\Product; -use A2lix\TranslationFormBundle\Tests\Fixtures\Form\MediaLocalizeType; -use A2lix\TranslationFormBundle\Tests\Form\TypeTestCase; +use Koff\Bundle\I18nFormBundle\Form\Type\TranslationsFormsType; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\MediaLocalize; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\Product; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Form\MediaLocalizeType; +use Koff\Bundle\I18nFormBundle\Tests\Form\TypeTestCase; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\PreloadedExtension; diff --git a/tests/Form/Type/TranslationsTypeAdvancedTest.php b/tests/Form/Type/TranslationsTypeAdvancedTest.php index 81b14e4..3e426a1 100644 --- a/tests/Form/Type/TranslationsTypeAdvancedTest.php +++ b/tests/Form/Type/TranslationsTypeAdvancedTest.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Form\Type; +namespace Koff\Bundle\I18nFormBundle\Tests\Form\Type; -use A2lix\TranslationFormBundle\Form\Type\TranslationsType; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\Product; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\ProductTranslation; -use A2lix\TranslationFormBundle\Tests\Form\TypeTestCase; +use Koff\Bundle\I18nFormBundle\Form\Type\TranslationsType; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\Product; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\ProductTranslation; +use Koff\Bundle\I18nFormBundle\Tests\Form\TypeTestCase; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\PreloadedExtension; diff --git a/tests/Form/Type/TranslationsTypeSimpleTest.php b/tests/Form/Type/TranslationsTypeSimpleTest.php index e071e33..fd03adc 100644 --- a/tests/Form/Type/TranslationsTypeSimpleTest.php +++ b/tests/Form/Type/TranslationsTypeSimpleTest.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Form\Type; +namespace Koff\Bundle\I18nFormBundle\Tests\Form\Type; -use A2lix\TranslationFormBundle\Form\Type\TranslationsType; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\Product; -use A2lix\TranslationFormBundle\Tests\Fixtures\Entity\ProductTranslation; -use A2lix\TranslationFormBundle\Tests\Form\TypeTestCase; +use Koff\Bundle\I18nFormBundle\Form\Type\TranslationsType; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\Product; +use Koff\Bundle\I18nFormBundle\Tests\Fixtures\Entity\ProductTranslation; +use Koff\Bundle\I18nFormBundle\Tests\Form\TypeTestCase; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\PreloadedExtension; diff --git a/tests/Form/TypeTestCase.php b/tests/Form/TypeTestCase.php index 01e18d1..7fcacc4 100644 --- a/tests/Form/TypeTestCase.php +++ b/tests/Form/TypeTestCase.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Form; +namespace Koff\Bundle\I18nFormBundle\Tests\Form; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\Setup; @@ -21,14 +21,14 @@ abstract class TypeTestCase extends BaseTypeTestCase { - /** @var DefaultManipulator */ + /** @var \Koff\Bundle\I18nFormBundle\Form\Manipulator\DefaultManipulator */ protected $defaultFormManipulator; protected function setUp() { parent::setUp(); - $validator = $this->getMock('\Symfony\Component\Validator\Validator\ValidatorInterface'); + $validator = $this->createMock('\Symfony\Component\Validator\Validator\ValidatorInterface'); $validator->method('validate')->will($this->returnValue(new ConstraintViolationList())); $this->factory = Forms::createFormFactoryBuilder() @@ -43,7 +43,7 @@ protected function setUp() ) ->getFormFactory(); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory); } @@ -55,31 +55,31 @@ protected function getDefaultFormManipulator() $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/../Fixtures/Entity'], true, null, null, false); $entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config); - $doctrineInfo = new \A2lix\AutoFormBundle\ObjectInfo\DoctrineInfo($entityManager->getMetadataFactory()); + $doctrineInfo = new \Koff\Bundle\I18nFormBundle\ObjectInfo\DoctrineInfo($entityManager->getMetadataFactory()); - return $this->defaultFormManipulator = new \A2lix\AutoFormBundle\Form\Manipulator\DefaultManipulator($doctrineInfo, ['id', 'locale', 'translatable']); + return $this->defaultFormManipulator = new \Koff\Bundle\I18nFormBundle\Form\Manipulator\DefaultManipulator($doctrineInfo, ['id', 'locale', 'translatable']); } protected function getConfiguredAutoFormType() { - $AutoFormListener = new \A2lix\AutoFormBundle\Form\EventListener\AutoFormListener($this->getDefaultFormManipulator()); + $AutoFormListener = new \Koff\Bundle\I18nFormBundle\Form\EventListener\AutoFormListener($this->getDefaultFormManipulator()); - return new \A2lix\AutoFormBundle\Form\Type\AutoFormType($AutoFormListener); + return new \Koff\Bundle\I18nFormBundle\Form\Type\AutoFormType($AutoFormListener); } protected function getConfiguredTranslationsType($locales, $defaultLocale, $requiredLocales) { - $translationsListener = new \A2lix\TranslationFormBundle\Form\EventListener\TranslationsListener($this->getDefaultFormManipulator()); - $localProvider = new \A2lix\TranslationFormBundle\Locale\DefaultProvider($locales, $defaultLocale, $requiredLocales); + $translationsListener = new \Koff\Bundle\I18nFormBundle\Form\EventListener\TranslationsListener($this->getDefaultFormManipulator()); + $localProvider = new \Koff\Bundle\I18nFormBundle\Locale\DefaultProvider($locales, $defaultLocale, $requiredLocales); - return new \A2lix\TranslationFormBundle\Form\Type\TranslationsType($translationsListener, $localProvider); + return new \Koff\Bundle\I18nFormBundle\Form\Type\TranslationsType($translationsListener, $localProvider); } protected function getConfiguredTranslationsFormsType($locales, $defaultLocale, $requiredLocales) { - $translationsFormsListener = new \A2lix\TranslationFormBundle\Form\EventListener\TranslationsFormsListener($this->getDefaultFormManipulator()); - $localProvider = new \A2lix\TranslationFormBundle\Locale\DefaultProvider($locales, $defaultLocale, $requiredLocales); + $translationsFormsListener = new \Koff\Bundle\I18nFormBundle\Form\EventListener\TranslationsFormsListener(); + $localProvider = new \Koff\Bundle\I18nFormBundle\Locale\DefaultProvider($locales, $defaultLocale, $requiredLocales); - return new \A2lix\TranslationFormBundle\Form\Type\TranslationsFormsType($translationsFormsListener, $localProvider); + return new \Koff\Bundle\I18nFormBundle\Form\Type\TranslationsFormsType($translationsFormsListener, $localProvider); } } diff --git a/tests/Locale/DefaultProviderTest.php b/tests/Locale/DefaultProviderTest.php index 4c53dc7..0a642f6 100644 --- a/tests/Locale/DefaultProviderTest.php +++ b/tests/Locale/DefaultProviderTest.php @@ -9,11 +9,12 @@ * file that was distributed with this source code. */ -namespace A2lix\TranslationFormBundle\Tests\Locale; +namespace Koff\Bundle\I18nFormBundle\Tests\Locale; -use A2lix\TranslationFormBundle\Locale\DefaultProvider; +use PHPUnit\Framework\TestCase; +use Koff\Bundle\I18nFormBundle\Locale\DefaultProvider; -class DefaultProviderTest extends \PHPUnit_Framework_TestCase +class DefaultProviderTest extends TestCase { protected $locales; protected $defaultLocale; @@ -31,7 +32,7 @@ public function setUp() public function testDefaultLocaleIsInLocales() { - $classname = 'A2lix\TranslationFormBundle\Locale\DefaultProvider'; + $classname = 'Koff\Bundle\I18nFormBundle\Locale\DefaultProvider'; // Get mock, without the constructor being called $mock = $this->getMockBuilder($classname) @@ -39,7 +40,7 @@ public function testDefaultLocaleIsInLocales() ->getMock(); // set expectations for constructor calls - $this->setExpectedException( + $this->expectException( 'InvalidArgumentException', 'Default locale `de` not found within the configured locales `[es,en]`.' . ' Perhaps you need to add it to your `koff_i18n_form.locales` bundle configuration?' ); @@ -52,7 +53,7 @@ public function testDefaultLocaleIsInLocales() public function testRequiredLocaleAreInLocales() { - $classname = 'A2lix\TranslationFormBundle\Locale\DefaultProvider'; + $classname = 'Koff\Bundle\I18nFormBundle\Locale\DefaultProvider'; // Get mock, without the constructor being called $mock = $this->getMockBuilder($classname) @@ -60,7 +61,7 @@ public function testRequiredLocaleAreInLocales() ->getMock(); // set expectations for constructor calls - $this->setExpectedException( + $this->expectException( 'InvalidArgumentException', 'Required locales should be contained in locales' );