Skip to content

Commit

Permalink
step 5: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sadikoff committed Dec 19, 2017
1 parent 30e9a7a commit df7e66c
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion tests/Fixtures/Entity/MediaLocalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Entity/ProductTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/Form/MediaLocalizeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
]);
}
}
10 changes: 5 additions & 5 deletions tests/Form/Type/TranslationsFormsTypeAdvancedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions tests/Form/Type/TranslationsFormsTypeSimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions tests/Form/Type/TranslationsTypeAdvancedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions tests/Form/Type/TranslationsTypeSimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 14 additions & 14 deletions tests/Form/TypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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);
}

Expand All @@ -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);
}
}
15 changes: 8 additions & 7 deletions tests/Locale/DefaultProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,15 +32,15 @@ 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)
->disableOriginalConstructor()
->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?'
);
Expand All @@ -52,15 +53,15 @@ 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)
->disableOriginalConstructor()
->getMock();

// set expectations for constructor calls
$this->setExpectedException(
$this->expectException(
'InvalidArgumentException', 'Required locales should be contained in locales'
);

Expand Down

0 comments on commit df7e66c

Please sign in to comment.