Skip to content

Commit

Permalink
Update minimum PHP version to 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanueleMinotto committed May 31, 2016
1 parent 0f960d0 commit b1410ef
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 51 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ cache:

matrix:
include:
- php: 5.4
- php: 5.5
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
Expand Down
32 changes: 12 additions & 20 deletions Tests/DependencyInjection/AeFeatureExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace Ae\FeatureBundle\Tests\DependencyInjection;

use Ae\FeatureBundle\DependencyInjection\AeFeatureExtension;
use Ae\FeatureBundle\Entity\FeatureManager;
use Ae\FeatureBundle\Security\FeatureSecurity;
use Ae\FeatureBundle\Service\Feature;
use Ae\FeatureBundle\Twig\Extension\FeatureExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;

/**
Expand Down Expand Up @@ -69,18 +73,12 @@ public function testParameters($parameterName, $expectedParameterValue)
public function parametersProvider()
{
return [
[
'ae_feature.manager.class',
'Ae\FeatureBundle\Entity\FeatureManager',
],
[
'ae_feature.security.class',
'Ae\FeatureBundle\Security\FeatureSecurity',
],
['ae_feature.feature.class', 'Ae\FeatureBundle\Service\Feature'],
['ae_feature.manager.class', FeatureManager::class],
['ae_feature.security.class', FeatureSecurity::class],
['ae_feature.feature.class', Feature::class],
[
'ae_feature.twig.extension.feature.class',
'Ae\FeatureBundle\Twig\Extension\FeatureExtension',
FeatureExtension::class,
],
];
}
Expand Down Expand Up @@ -129,16 +127,10 @@ public function testServices($serviceId, $expectedClass)
public function servicesProvider()
{
return [
['ae_feature.manager', 'Ae\FeatureBundle\Entity\FeatureManager'],
[
'ae_feature.security',
'Ae\FeatureBundle\Security\FeatureSecurity',
],
['ae_feature.feature', 'Ae\FeatureBundle\Service\Feature'],
[
'ae_feature.twig.extension.feature',
'Ae\FeatureBundle\Twig\Extension\FeatureExtension',
],
['ae_feature.manager', FeatureManager::class],
['ae_feature.security', FeatureSecurity::class],
['ae_feature.feature', Feature::class],
['ae_feature.twig.extension.feature', FeatureExtension::class],
];
}
}
22 changes: 14 additions & 8 deletions Tests/Entity/FeatureManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Ae\FeatureBundle\Tests\Entity;

use Ae\FeatureBundle\Entity\Feature;
use Ae\FeatureBundle\Entity\FeatureManager;
use Doctrine\ORM\EntityManager;
use PHPUnit_Framework_TestCase;

/**
Expand All @@ -16,11 +18,12 @@ class FeatureManagerTest extends PHPUnit_Framework_TestCase

protected function setUp()
{
$this->em = $this->getMockBuilder('\Doctrine\ORM\EntityManager')
$this->em = $this
->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
$this->manager = $this
->getMockBuilder('\Ae\FeatureBundle\Entity\FeatureManager')
->getMockBuilder(FeatureManager::class)
->setConstructorArgs([$this->em])
->setMethods(['emptyCache'])
->getMock();
Expand All @@ -29,7 +32,7 @@ protected function setUp()
public function testCreate()
{
$name = 'foo';
$parent = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$parent = $this->getMock(Feature::class);

$feature = $this->manager->create($name, $parent);
$this->assertEquals($name, $feature->getName($name));
Expand All @@ -38,15 +41,18 @@ public function testCreate()

public function testUpdate()
{
$feature = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$parent = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$feature->expects($this->once())
$feature = $this->getMock(Feature::class);
$parent = $this->getMock(Feature::class);
$feature
->expects($this->once())
->method('getParent')
->will($this->returnValue($parent));
$this->em->expects($this->once())
$this->em
->expects($this->once())
->method('persist')
->with($feature);
$this->em->expects($this->once())
$this->em
->expects($this->once())
->method('flush');
$this->manager->update($feature);
}
Expand Down
10 changes: 4 additions & 6 deletions Tests/Entity/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ae\FeatureBundle\Tests\Entity;

use Ae\FeatureBundle\Entity\Feature;
use Doctrine\Common\Collections\Collection;
use PHPUnit_Framework_TestCase;

/**
Expand All @@ -23,20 +24,17 @@ protected function setUp()
*/
public function testParent()
{
$parent = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$parent = $this->getMock(Feature::class);
$this->entity->setParent($parent);
$this->assertEquals($parent, $this->entity->getParent());
}

public function testChildren()
{
$parent = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$parent = $this->getMock(Feature::class);
$this->entity->addFeature($parent);
$collection = $this->entity->getChildren();
$this->assertInstanceOf(
'Doctrine\Common\Collections\Collection',
$collection
);
$this->assertInstanceOf(Collection::class, $collection);
$this->assertEquals($parent, $collection->first());
}

Expand Down
14 changes: 7 additions & 7 deletions Tests/Security/FeatureSecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Ae\FeatureBundle\Tests\Security;

use Ae\FeatureBundle\Entity\Feature;
use Ae\FeatureBundle\Security\FeatureSecurity;
use PHPUnit_Framework_TestCase;
use Symfony\Component\Security\Core\SecurityContextInterface;

/**
* @author Carlo Forghieri <carlo@adespresso.com>
Expand All @@ -16,9 +18,7 @@ class FeatureSecurityTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$context = $this
->getMockBuilder(
'\Symfony\Component\Security\Core\SecurityContextInterface'
)
->getMockBuilder(SecurityContextInterface::class)
->disableOriginalConstructor()
->getMock();
$context->expects($this->any())
Expand All @@ -45,21 +45,21 @@ public function getFeatures()
{
$tests = [];

$feature = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$feature = $this->getMock(Feature::class);
$feature
->expects($this->once())
->method('isEnabled')
->will($this->returnValue(false));
$tests[] = [$feature, false];

$feature = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$feature = $this->getMock(Feature::class);
$feature
->expects($this->once())
->method('isEnabled')
->will($this->returnValue(true));
$tests[] = [$feature, true];

$feature = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$feature = $this->getMock(Feature::class);
$feature
->expects($this->once())
->method('isEnabled')
Expand All @@ -70,7 +70,7 @@ public function getFeatures()
->will($this->returnValue('ROLE_USER'));
$tests[] = [$feature, true];

$feature = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$feature = $this->getMock(Feature::class);
$feature
->expects($this->once())
->method('isEnabled')
Expand Down
15 changes: 9 additions & 6 deletions Tests/Service/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Ae\FeatureBundle\Tests\Service;

use Ae\FeatureBundle\Service\Feature;
use Ae\FeatureBundle\Entity\Feature;
use Ae\FeatureBundle\Entity\FeatureManager;
use Ae\FeatureBundle\Security\FeatureSecurity;
use Ae\FeatureBundle\Service\Feature as FeatureService;
use PHPUnit_Framework_TestCase;

/**
Expand All @@ -18,19 +21,19 @@ class FeatureTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$this->manager = $this
->getMockBuilder('Ae\FeatureBundle\Entity\FeatureManager')
->getMockBuilder(FeatureManager::class)
->disableOriginalConstructor()
->getMock();
$this->security = $this
->getMockBuilder('Ae\FeatureBundle\Security\FeatureSecurity')
->getMockBuilder(FeatureSecurity::class)
->disableOriginalConstructor()
->getMock();
$this->service = new Feature($this->manager, $this->security);
$this->service = new FeatureService($this->manager, $this->security);
}

public function testIsGrantedTrue()
{
$featureEnabled = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$featureEnabled = $this->getMock(Feature::class);
$this->manager
->expects($this->atLeastOnce())
->method('find')
Expand All @@ -49,7 +52,7 @@ public function testIsGrantedTrue()

public function testIsGrantedFalse()
{
$featureDisabled = $this->getMock('Ae\FeatureBundle\Entity\Feature');
$featureDisabled = $this->getMock(Feature::class);
$this->manager
->expects($this->atLeastOnce())
->method('find')
Expand Down
3 changes: 2 additions & 1 deletion Tests/Twig/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Ae\FeatureBundle\Tests\Twig;

use Ae\FeatureBundle\Service\Feature;
use Ae\FeatureBundle\Twig\Extension\FeatureExtension;
use Twig_Test_IntegrationTestCase;

Expand All @@ -14,7 +15,7 @@ class IntegrationTest extends Twig_Test_IntegrationTestCase
public function getExtensions()
{
$service = $this
->getMockBuilder('Ae\FeatureBundle\Service\Feature')
->getMockBuilder(Feature::class)
->disableOriginalConstructor()
->getMock();
$service
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"license": "Apache-2.0",
"name": "adespresso/feature-bundle",
"require": {
"php": "^5.4 || ^7.0",
"php": "^5.5 || ^7.0",
"doctrine/orm": "^2.2.3",
"friendsofsymfony/user-bundle": "1.3.*",
"sonata-project/admin-bundle": "^2.3.4",
Expand Down

0 comments on commit b1410ef

Please sign in to comment.