Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ease testing #583

Merged
merged 1 commit into from
Oct 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ vendor/
.php_cs.cache
dist/
bin/
!bin/test.sh
vendor-bin/*/vendor/
humbuglog.txt
25 changes: 12 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ Main differences between 2.x and 3.x:

The two entry points of the library are the `DataLoader` and `FileLoader`:

![FileLoader](doc/img/FileLoader.png)
<a href="/nelmio/alice/blob/master/doc/img/FileLoader.png" target="_blank">
<img src="/nelmio/alice/raw/master/doc/img/FileLoader.png" alt="FileLoader" style="height: 300px; max-width:100%;">
</a>

![DataLoader](doc/img/DataLoader.png)
<a href="/nelmio/alice/blob/master/doc/img/DataLoader.png" target="_blank">
<img src="/nelmio/alice/raw/master/doc/img/DataLoader.png" alt="DataLoader" style="height: 300px; max-width:100%;">
</a>

Alice's goal is to render a PHP array containing a description of objects and parameters (with support for injected external objects
and parameters) into a set of objects called `ObjectSet`.
Expand Down Expand Up @@ -103,24 +107,19 @@ services with the right properties (like tags and configuration) to the framewor
other framework special features should be handled in another library, bundle, module etc.

To avoid any conflicts, the framework dependencies used by the bridges are installed in dedicated folders thanks to
[bamarni composer plugin][3]. As a result, if you want to run the tests for Symfony, you must run the tests with
[bamarni bin composer plugin][3] and [theofidry inheritance composer plugin][4]. As a result, if you want to run the tests for Symfony, you must run the tests with
`phpunit_symfony.xml.dist` instead of `phpunit.xml.dist`.

The test suite also uses the groups annotations:

- `integration`: integration tests
- `symfony`: Symfony bridge related tests
- no group: any unit test

For example to run only the Symfony bridge integration tests:

`$ vendor/bin/phpunit -c phpunit_symfony.xml.dist --group=integration,symfony`
To run the tests, simply run `bin/tests.sh`.

The tests should be descriptive and are "testdox friendly" i.e. if you are using the testdox
option, you will get something like:

![Testdox](doc/img/testdox.png)
<a href="/nelmio/alice/blob/master/doc/img/testdox.png" target="_blank">
<img src="/nelmio/alice/raw/master/doc/img/testdox.png" alt="Testdox" style="height: 250px; max-width:100%;">
</a>

[1]: https://github.com/fzaninotto/Faker
[2]: https://github.com/sebastianbergmann/phpunit
[3]: https://github.com/bamarni/composer-bin-plugin
[4]: https://github.com/theofidry/composer-inheritance-plugin
28 changes: 28 additions & 0 deletions bin/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

#
# This file is part of the Alice package.
#
# (c) Nelmio <hello@nelm.io>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#

export INFO_COLOR="\e[34m"
export NO_COLOR="\e[0m"

log() {
local message=$1;
echo -en "${INFO_COLOR}${message}${NO_COLOR}\n";
}

set -e

log "Core library"
vendor/bin/phpunit -c phpunit.xml.dist

log "Symfony bridge"
rm -rf fixtures/Bridge/Symfony/Application/cache/*

vendor-bin/symfony/bin/phpunit -c phpunit_symfony.xml.dist
20 changes: 13 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ This file is part of the Alice package.
~
~ (c) Nelmio <hello@nelm.io>
~
~ For the full copyright and license information, please view the LICENSE
~ file that was distributed with this source code.
-->

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
Expand Down Expand Up @@ -42,19 +52,15 @@
<file>tests/FixtureBuilder/ExpressionLanguage/TokenTest.php</file>
</testsuite>
<testsuite name="Independent tests">
<directory>tests/</directory>
<directory>tests</directory>
<exclude>tests/Bridge</exclude>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>symfony</group>
</exclude>
</groups>

<filter>
<whitelist>
<directory>src</directory>
<exclude>src/Bridge</exclude>
</whitelist>
</filter>

Expand Down
38 changes: 3 additions & 35 deletions phpunit_symfony.xml.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ This file is part of the Alice package.
~
Expand All @@ -17,47 +18,14 @@
>

<testsuites>
<testsuite name="Dependent tests">
<file>tests/Definition/PropertyTest.php</file>
<file>tests/Definition/PropertyBagTest.php</file>
<file>tests/Definition/MethodCallBagTest.php</file>
<file>tests/Definition/SpecificationBagTest.php</file>
<file>tests/Definition/FlagBagTest.php</file>
<file>tests/Definition/Fixture/SimpleFixtureTest.php</file>
<file>tests/Definition/Fixture/SimpleFixtureWithFlagsTest.php</file>
<file>tests/Definition/Fixture/TemplatingFixtureTest.php</file>
<file>tests/Definition/ServiceReference/FixtureReferenceTest.php</file>
<file>tests/Definition/Fixture/TemplatingTest.php</file>
<file>tests/Definition/MethodCall/OptionalMethodCallTest.php</file>
<file>tests/Definition/Value/FunctionCallValueTest.php</file>
<file>tests/Definition/Value/FixtureMethodCallValueTest.php</file>
<file>tests/Definition/Value/FixtureReferenceValueTest.php</file>
<file>tests/Definition/Value/FixturePropertyValueTest.php</file>
<file>tests/Definition/Value/FixturePropertyValueTest.php</file>
<file>tests/Definition/Value/UniqueValueTest.php</file>
<file>tests/ParameterTest.php</file>
<file>tests/ParameterBagTest.php</file>
<file>tests/FixtureBagTest.php</file>
<file>tests/Definition/Object/SimpleObjectTest.php</file>
<file>tests/ObjectBagTest.php</file>
<file>tests/ObjectSetTest.php</file>
<file>tests/FixtureSetTest.php</file>
<file>tests/FixtureBuilder/BareFixtureSetTest.php</file>
<file>tests/Generator/ResolvedFixtureSetTest.php</file>
<file>tests/Generator/ResolvedValueWithFixtureSetTest.php</file>
<file>tests/Generator/Resolver/Fixture/TemplatingFixtureBagTest.php</file>
<file>tests/Generator/Resolver/UniqueValuesPoolTest.php</file>
<file>tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php</file>
<file>tests/FixtureBuilder/ExpressionLanguage/TokenTest.php</file>
</testsuite>
<testsuite name="Independent tests">
<directory>tests/</directory>
<directory>tests/Bridge/Symfony</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
<directory>src/Bridge/Symfony</directory>
</whitelist>
</filter>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</service>

<service id="nelmio_alice.generator.resolver.value.chainable.unresolved_fixture_reference_resolver"
class="Nelmio\Alice\Generator\Resolver\Value\Chainable\UnresolvedFixtureReferenceResolver">
class="Nelmio\Alice\Generator\Resolver\Value\Chainable\UnresolvedFixtureReferenceIdResolver">
<argument type="service" id="nelmio_alice.generator.resolver.value.chainable.self_fixture_reference_resolver" />

<tag name="nelmio_alice.generator.resolver.value.chainable_resolver" />
Expand Down
1 change: 0 additions & 1 deletion tests/Bridge/Symfony/Application/cache/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/**
* @covers \Nelmio\Alice\Bridge\Symfony\DependencyInjection\Configuration
* @group integration
* @group symfony
*/
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* @coversNothing
*
* @group integration
* @group symfony
*/
class DynamicServicesConfigurationTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -34,7 +33,7 @@ class DynamicServicesConfigurationTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->kernel = KernelFactory::createKernel(__DIR__.'/../Application/config_custom.yml');
$this->kernel = KernelFactory::createKernel(__DIR__.'/../../../../fixtures/Bridge/Symfony/Application/config_custom.yml');
$this->kernel->boot();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* {@inheritdoc}
*
* @group integration
* @group symfony
*/
class LexerIntegrationTest extends \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\LexerIntegrationTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

/**
* @group integration
* @group symfony
*/
class ParserIntegrationTest extends \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\ParserIntegrationTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

/**
* @group integration
* @group symfony
*/
class ParameterResolverIntegrationTest extends \Nelmio\Alice\Generator\Resolver\ParameterResolverIntegrationTest
{
Expand Down
1 change: 0 additions & 1 deletion tests/Bridge/Symfony/Loader/LoaderIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

/**
* @group integration
* @group symfony
*/
class LoaderIntegrationTest extends \Nelmio\Alice\Loader\LoaderIntegrationTest
{
Expand Down