Skip to content

Commit

Permalink
Merge pull request #47 from mwadon/symfony4support
Browse files Browse the repository at this point in the history
Adding Symfony4 support
  • Loading branch information
willdurand authored Mar 28, 2018
2 parents 3bbfbec + 2d2990a commit de7709d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 7.1

matrix:
fast_finish: true
include:
- php: 5.3
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
- php: 5.6
env: SYMFONY_VERSION='2.8.*@dev' DEPENDENCIES=dev COMPOSER_FLAGS="--prefer-stable"
- php: 5.6
env: DEPENDENCIES=dev
- php: 7.1
env: DEPENDENCIES=beta

before_install:
- composer self-update
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/framework-bundle=$SYMFONY_VERSION; fi
- if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ "$DEPENDENCIES" = "beta" ]; then composer config minimum-stability beta; fi;

install: composer update $COMPOSER_FLAGS

script:
- phpunit --coverage-text
- ./vendor/bin/simple-phpunit
1 change: 1 addition & 0 deletions DependencyInjection/Compiler/AddProvidersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function process(ContainerBuilder $container)
$container
->getDefinition('faker.generator')
->addMethodCall('addProvider', array(new Reference($id)))
->setPublic(true)
;
}
}
Expand Down
17 changes: 14 additions & 3 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="faker.generator.class">Faker\Factory</parameter>
<parameter key="faker.populator.class">Faker\ORM\Propel\Populator</parameter>
<parameter key="faker.entity.class">Faker\ORM\Propel\EntityPopulator</parameter>
<parameter key="faker.populate_command.class">Bazinga\Bundle\FakerBundle\Command\PopulateCommand</parameter>
</parameters>

<services>
<service id="faker.generator" class="%faker.generator.class%" />

<service id="Faker\Factory" alias="faker.generator" />

<service id="faker.populator" class="%faker.populator.class%">
<argument type="service" id="faker.generator" />
<argument />
</service>

<service id="faker.formatter_factory" class="Bazinga\Bundle\FakerBundle\Factory\FormatterFactory"></service>
<service id="Faker\ORM\Propel\Populator" alias="faker.populator" />

<service id="faker.formatter_factory" class="Bazinga\Bundle\FakerBundle\Factory\FormatterFactory" />

<service id="Bazinga\Bundle\FakerBundle\Factory\FormatterFactory" alias="faker.formatter_factory" />

<service id="Bazinga\Bundle\FakerBundle\Command\PopulateCommand" class="%faker.populate.class%">
<tag name="console.command" />
</service>
</services>

</container>
7 changes: 5 additions & 2 deletions Tests/DependencyInjection/Compiler/AddProvidersPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ public function testProviderIsAdded()
$targetService = new Definition();
$targetService->setClass('Faker\Generator');

$provider = $this->getMock('Acme\Faker\Provider\CustomFakeDataProvider');
$provider = $this->getMockBuilder('Acme\Faker\Provider\CustomFakeDataProvider')->getMock();
$providerService = new Definition();
$providerService->setClass(get_class($provider));
$providerService->addTag('bazinga_faker.provider');
$providerService
->addTag('bazinga_faker.provider')
->setPublic(true)
;

$builder = new ContainerBuilder();
$builder->addDefinitions(array(
Expand Down
18 changes: 15 additions & 3 deletions Tests/Factory/FormatterFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ class FormatterFactoryTest extends TestCase
{
public function testCreateClosureWithoutParameters()
{
$generator = $this->getMock('Faker\Generator', array('foo'));
$generator = $this
->getMockBuilder('Faker\Generator')
->setMethods(array('foo', 'optional'))
->getMock()
;
$generator
->expects($this->once())
->method('foo')
Expand All @@ -35,7 +39,11 @@ public function testCreateClosureWithoutParameters()

public function testCreateClosureWithOptional()
{
$generator = $this->getMock('Faker\Generator', array('foo','optional'));
$generator = $this
->getMockBuilder('Faker\Generator')
->setMethods(array('foo','optional'))
->getMock()
;
$generator
->expects($this->once())
->method('foo')
Expand Down Expand Up @@ -66,7 +74,11 @@ public function withParameterProvider()
*/
public function testCreateClosureWithParameters(array $parameters)
{
$generator = $this->getMock('Faker\Generator', array('foo'));
$generator = $this
->getMockBuilder('Faker\Generator')
->setMethods(array('foo'))
->getMock()
;
$matcher = $generator
->expects($this->once())
->method('foo')
Expand Down
2 changes: 1 addition & 1 deletion Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
/**
* @author William Durand <[email protected]>
*/
class TestCase extends \PHPUnit_Framework_TestCase
class TestCase extends \PHPUnit\Framework\TestCase
{
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
],
"require": {
"php": ">=5.3",
"symfony/framework-bundle": "~2.3|~3.0",
"symfony/framework-bundle": "~2.3|~3.0|^4.0",
"fzaninotto/faker": "~1.3"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7|~3.0"
"symfony/phpunit-bridge": "^4.0"
},
"autoload": {
"psr-0": { "Bazinga\\Bundle\\FakerBundle": "" }
Expand Down

0 comments on commit de7709d

Please sign in to comment.