Forráskód Böngészése

remove files and fix tests

Thomas Rabaix 11 éve
szülő
commit
7816c8c037

+ 9 - 0
DependencyInjection/SonataAdminExtension.php

@@ -35,6 +35,15 @@ class SonataAdminExtension extends Extension
     public function load(array $configs, ContainerBuilder $container)
     {
         $bundles = $container->getParameter('kernel.bundles');
+
+        if (!isset($bundles['SonataCoreBundle'])) {
+            throw new \RuntimeException(<<<BOOM
+Boom! you are living on the edge ;) The AdminBundle requires the CoreBundle!
+Please add ``"sonata-project/core-bundle": "~2.2@dev`` into your composer.json file and add the SonataCoreBundle into the AppKernel');
+BOOM
+            );
+        }
+
         if (isset($bundles['SonataUserBundle'])) {
             // integrate the SonataUserBundle / FOSUserBundle if the bundle exists
             array_unshift($configs, array(

+ 3 - 1
Tests/DependencyInjection/Compiler/AddDependencyCallsCompilerPassTest.php

@@ -170,7 +170,9 @@ class AddDependencyCallsCompilerPassTest extends \PHPUnit_Framework_TestCase
     private function getContainer()
     {
         $container = new ContainerBuilder();
-        $container->setParameter('kernel.bundles', array());
+        $container->setParameter('kernel.bundles', array(
+            'SonataCoreBundle' => true
+        ));
 
         // Add dependencies for SonataAdminBundle (these services will never get called so dummy classes will do)
         $container

+ 5 - 3
Tests/DependencyInjection/Compiler/ExtensionCompilerPassTest.php

@@ -78,8 +78,8 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
         $extensionMap = $container->getParameter($this->root . ".extension.map");
 
         $method = new \ReflectionMethod(
-                  'Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass', 'flattenExtensionConfiguration'
-                );
+          'Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass', 'flattenExtensionConfiguration'
+        );
 
         $method->setAccessible(TRUE);
         $extensionMap = $method->invokeArgs(new ExtensionCompilerPass(), array($extensionMap));
@@ -278,7 +278,9 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
     private function getContainer()
     {
         $container = new ContainerBuilder();
-        $container->setParameter('kernel.bundles', array());
+        $container->setParameter('kernel.bundles', array(
+            'SonataCoreBundle' => true
+        ));
 
         // Add dependencies for SonataAdminBundle (these services will never get called so dummy classes will do)
         $container

+ 0 - 50
Tests/Form/DataTransformer/BooleanTypeToBooleanTransformerTest.php

@@ -1,50 +0,0 @@
-<?php
-
-/*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Sonata\AdminBundle\Tests\Form\DataTransformer;
-
-use Sonata\AdminBundle\Form\Type\BooleanType;
-use Sonata\AdminBundle\Form\DataTransformer\BooleanTypeToBooleanTransformer;
-
-class BooleanTypeToBooleanTransformerTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @dataProvider getReverseTransformData
-     */
-    public function testReverseTransform($value, $expected)
-    {
-        $transformer = new BooleanTypeToBooleanTransformer();
-
-        $this->assertEquals($expected, $transformer->transform($value));
-    }
-
-    public function testTransform()
-    {
-        $transformer = new BooleanTypeToBooleanTransformer();
-        $this->assertTrue($transformer->reverseTransform(BooleanType::TYPE_YES));
-        $this->assertTrue($transformer->reverseTransform(1));
-        $this->assertFalse($transformer->reverseTransform('asd'));
-        $this->assertFalse($transformer->reverseTransform(BooleanType::TYPE_NO));
-    }
-
-    public function getReverseTransformData()
-    {
-        return array(
-            array(true, BooleanType::TYPE_YES),
-            array(false, BooleanType::TYPE_NO),
-            array("wrong", BooleanType::TYPE_NO),
-            array("1", BooleanType::TYPE_YES),
-            array("2", BooleanType::TYPE_NO),
-
-            array("3", BooleanType::TYPE_NO), // default value is false ...
-        );
-    }
-}

+ 0 - 64
Tests/Form/Type/BooleanTypeTest.php

@@ -1,64 +0,0 @@
-<?php
-
-/*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Sonata\AdminBundle\Tests\Form\Type;
-
-use Sonata\AdminBundle\Form\Type\BooleanType;
-use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
-use Symfony\Component\OptionsResolver\OptionsResolver;
-
-class BooleanTypeTest extends TypeTestCase
-{
-    public function testGetDefaultOptions()
-    {
-        $type = new BooleanType();
-
-        $optionResolver = new OptionsResolver();
-
-        $this->assertEquals('sonata_type_translatable_choice', $type->getParent());
-
-        $type->setDefaultOptions($optionResolver);
-
-        $options = $optionResolver->resolve();
-
-        $this->assertEquals(2, count($options['choices']));
-    }
-
-    public function testAddTransformerCall()
-    {
-        $type = new BooleanType();
-
-        $type->setDefaultOptions($optionResolver = new OptionsResolver());
-
-        $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
-        $builder->expects($this->once())->method('addModelTransformer');
-
-        $type->buildForm($builder, $optionResolver->resolve(array(
-            'transform' => true,
-        )));
-    }
-
-    /**
-     * The default behavior is not to transform to real boolean value .... don't ask
-     *
-     */
-    public function testDefaultBehavior()
-    {
-        $type = new BooleanType();
-
-        $type->setDefaultOptions($optionResolver = new OptionsResolver());
-
-        $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
-        $builder->expects($this->never())->method('addModelTransformer');
-
-        $type->buildForm($builder, $optionResolver->resolve(array()));
-    }
-}

+ 0 - 36
Tests/Form/Type/CollectionTypeTest.php

@@ -1,36 +0,0 @@
-<?php
-
-/*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Sonata\AdminBundle\Tests\Form\Type;
-
-use Sonata\AdminBundle\Form\Type\CollectionType;
-use Symfony\Component\Form\Test\TypeTestCase;
-use Symfony\Component\OptionsResolver\OptionsResolver;
-
-class CollectionTypeTest extends TypeTestCase
-{
-    public function testGetDefaultOptions()
-    {
-        $type = new CollectionType();
-
-        $optionResolver = new OptionsResolver();
-
-        $type->setDefaultOptions($optionResolver);
-
-        $options = $optionResolver->resolve();
-
-        $this->assertFalse($options['modifiable']);
-        $this->assertEquals('text', $options['type']);
-        $this->assertEquals(0, count($options['type_options']));
-        $this->assertEquals('link_add', $options['btn_add']);
-        $this->assertEquals('SonataAdminBundle', $options['btn_catalogue']);
-    }
-}

+ 0 - 47
Tests/Form/Type/StatusTypeTest.php

@@ -1,47 +0,0 @@
-<?php
-
-/*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Sonata\AdminBundle\Tests\Form\Type;
-
-use Sonata\AdminBundle\Form\Type\StatusType;
-
-use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
-use Symfony\Component\OptionsResolver\OptionsResolver;
-
-class Choice
-{
-    public static function getList()
-    {
-        return array(
-            1 => 'salut'
-        );
-    }
-}
-
-class StatusTypeTest extends TypeTestCase
-{
-    public function testGetDefaultOptions()
-    {
-        $type = new StatusType('Sonata\AdminBundle\Tests\Form\Type\Choice', 'getList', 'choice_type');
-
-        $this->assertEquals('choice_type', $type->getName());
-        $this->assertEquals('choice', $type->getParent());
-
-        $optionResolver = new OptionsResolver();
-
-        $type->setDefaultOptions($optionResolver);
-
-        $options = $optionResolver->resolve(array());
-
-        $this->assertArrayHasKey('choices', $options);
-        $this->assertEquals($options['choices'], array(1 => 'salut'));
-    }
-}

+ 0 - 36
Tests/Form/Type/TranslatableChoiceTypeTest.php

@@ -1,36 +0,0 @@
-<?php
-
-/*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Sonata\AdminBundle\Tests\Form\Type;
-
-use Sonata\AdminBundle\Form\Type\TranslatableChoiceType;
-use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
-use Symfony\Component\OptionsResolver\OptionsResolver;
-
-class TranslatableChoiceTypeTest extends TypeTestCase
-{
-    public function testGetDefaultOptions()
-    {
-        $stub = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
-
-        $type = new TranslatableChoiceType($stub);
-
-        $optionResolver = new OptionsResolver();
-
-        $this->assertEquals('choice', $type->getParent());
-
-        $type->setDefaultOptions($optionResolver);
-
-        $options = $optionResolver->resolve(array('catalogue' => 'foo'));
-
-        $this->assertEquals('foo', $options['catalogue']);
-    }
-}