From 0f2f72ff0c2316eda88e7bce1cb43451df78426a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Poskin?= Date: Sat, 26 Sep 2015 01:18:56 +0200 Subject: [PATCH] BC Remove deprecated code for Symfony 2.7 and add tests --- .../Twig/Extension/BootstrapExtensionTest.php | 49 +++++++++++++++++++ Tests/bootstrap.php | 3 ++ Twig/Extension/BootstrapExtension.php | 4 +- composer.json | 15 ++++-- phpunit.xml.dist | 21 ++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 Tests/Twig/Extension/BootstrapExtensionTest.php create mode 100644 Tests/bootstrap.php create mode 100644 phpunit.xml.dist diff --git a/Tests/Twig/Extension/BootstrapExtensionTest.php b/Tests/Twig/Extension/BootstrapExtensionTest.php new file mode 100644 index 0000000..6d479fa --- /dev/null +++ b/Tests/Twig/Extension/BootstrapExtensionTest.php @@ -0,0 +1,49 @@ +extension = new BootstrapExtension(); + } + + /** + * Test that the name is correctly set + */ + public function testGetName() + { + $this->assertSame('snowcap_bootstrap', $this->extension->getName(), 'getName: '); + } + + /** + * Test that the functions are correctly set + */ + public function testGetFunctions() + { + $filters = $this->extension->getFunctions(); + $this->assertInstanceOf('\Twig_SimpleFunction', $filters['form_row_classes']); + } + + /** + * Test the getFormRowClasses method + */ + public function testGetFormRowClasses() + { + $this->assertEquals('type_foo', $this->extension->getFormRowClasses(['foo'])); + $this->assertEquals('type_bar', $this->extension->getFormRowClasses(['bar'])); + $this->assertEquals('type_foo type_bar', $this->extension->getFormRowClasses(['foo', 'bar'])); + } +} \ No newline at end of file diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php new file mode 100644 index 0000000..c55fb89 --- /dev/null +++ b/Tests/bootstrap.php @@ -0,0 +1,3 @@ + new \Twig_Function_Method($this, 'getFormRowClasses'), + 'form_row_classes' => new \Twig_SimpleFunction($this, 'getFormRowClasses'), ); } diff --git a/composer.json b/composer.json index fab214a..79d033c 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,13 @@ "homepage": "http://www.snowcap.be" } ], - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.3.2", - "symfony/framework-bundle": ">=2.2", - "leafo/lessphp": "v0.4.0" + "symfony/framework-bundle": "^2.7", + "leafo/lessphp": "v0.4.0", + "twig/twig": "^1.22", + "symfony/form": "^2.7" }, "autoload": { "psr-0": { "Snowcap\\BootstrapBundle": "" } @@ -35,7 +37,12 @@ "target-dir": "Snowcap/BootstrapBundle", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "1.0.x-dev" } + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "symfony/phpunit-bridge": "^2.7", + "doctrine/annotations": "^1.2" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..6bf1fb5 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Tests + ./vendor + + + + \ No newline at end of file