Skip to content

Commit

Permalink
BC Remove deprecated code for Symfony 2.7 and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Poskin committed Sep 25, 2015
1 parent 1394df0 commit 0f2f72f
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 7 deletions.
49 changes: 49 additions & 0 deletions Tests/Twig/Extension/BootstrapExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Snowcap\BootstrapBundle\Tests\Twig\Extension;

use Snowcap\BootstrapBundle\Twig\Extension\BootstrapExtension;

class BootstrapExtensionTest extends \PHPUnit_Framework_TestCase
{

/**
* @var BootstrapExtension
*/
private $extension;

/**
* Sets the extension
*/
public function setUp()
{
$this->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']));
}
}
3 changes: 3 additions & 0 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
4 changes: 1 addition & 3 deletions Twig/Extension/BootstrapExtension.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
namespace Snowcap\BootstrapBundle\Twig\Extension;

use Symfony\Component\Form\Util\PropertyPath;

/**
* Created by JetBrains PhpStorm.
* User: edwin
Expand Down Expand Up @@ -30,7 +28,7 @@ public function initRuntime(\Twig_Environment $environment)
public function getFunctions()
{
return array(
'form_row_classes' => new \Twig_Function_Method($this, 'getFormRowClasses'),
'form_row_classes' => new \Twig_SimpleFunction($this, 'getFormRowClasses'),
);
}

Expand Down
15 changes: 11 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@
"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": "" }
},
"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"
}
}
21 changes: 21 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
bootstrap="Tests/bootstrap.php"
>
<testsuites>
<testsuite name="Snowcap BootstrapBundle Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 0f2f72f

Please sign in to comment.