Skip to content

Commit

Permalink
Merge branch 'feature/atoum' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shulard committed Feb 18, 2016
2 parents 7dd0a94 + c6a71b6 commit 98dd0e4
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 236 deletions.
3 changes: 3 additions & 0 deletions .atoum.php
@@ -0,0 +1,3 @@
<?php

$runner->addTestsFromDirectory(__DIR__ . '/test/units');
4 changes: 4 additions & 0 deletions .bootstrap.atoum.php
@@ -0,0 +1,4 @@
<?php

require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/test/units/Adapters/AbstractAdapterTest.php';
16 changes: 12 additions & 4 deletions .travis.yml
Expand Up @@ -6,9 +6,17 @@ php:
- 5.5
- 5.4
install:
- composer install --no-interaction --prefer-source
- composer install:phpunit
script: bin/phpunit --coverage-clover=coverage.clover
- composer self-update && composer install --no-interaction --prefer-source
script:
- vendor/bin/atoum
- vendor/bin/phpcs --standard=phpcs.xml
after_script:
- |
echo "
\$clover = new atoum\\reports\\asynchronous\\clover();
\$runner->addReport(\$clover);
\$writer = new atoum\\writers\\file('atoum.clover');
\$clover->addWriter(\$writer);
" >> .atoum.php && vendor/bin/atoum
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- php ocular.phar code-coverage:upload --format=php-clover atoum.clover
1 change: 0 additions & 1 deletion bin/.gitkeep

This file was deleted.

26 changes: 7 additions & 19 deletions composer.json
@@ -1,13 +1,10 @@
{
"name": "bee4/events",
"description": "Basic event dispatcher definition, to allow a project to allow to manage events",
"description": "Basic event dispatcher definition, implement basic Mediator pattern",
"license": "Apache-2.0",
"config": {
"bin-dir": "bin"
},
"authors": [
{
"name": "Stephane HULARD",
"name": "Stéphane HULARD",
"email": "s.hulard@chstudio.fr"
}
],
Expand All @@ -16,26 +13,17 @@
},
"require-dev": {
"symfony/event-dispatcher": "~2.5",
"evenement/evenement": "~2.0.0"
"evenement/evenement": "~2.0.0",
"atoum/atoum": "~2.5",
"squizlabs/php_codesniffer": "~2.5"
},
"autoload": {
"psr-4": {
"Bee4\\Events\\": "src"
}
},
"suggest": {
"symfony/event-dispatcher": "Required if using Symfony dispatcher adapter",
"evenement/evenement": "Required if using Événement dispatcher adapter"
},
"scripts": {
"install:phpunit": [
"mkdir -p bin && php -r \"file_put_contents('bin/phpunit', file_get_contents('https://phar.phpunit.de/phpunit-4.7.7.phar'));\"",
"chmod 755 bin/phpunit"
],
"install:phpcodesniffer": [
"mkdir -p bin && php -r \"file_put_contents('bin/phpcs', file_get_contents('https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar'));\"",
"php -r \"file_put_contents('bin/phpcbf', file_get_contents('https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar'));\"",
"chmod 755 bin/phpcs bin/phpcbf"
]
"symfony/event-dispatcher": "Required to use Symfony dispatcher adapter",
"evenement/evenement": "Required to use Événement dispatcher adapter"
}
}
54 changes: 30 additions & 24 deletions phpcs.xml
@@ -1,36 +1,42 @@
<?xml version="1.0"?>
<ruleset name="BeeBOT">
<description>Specific BeeBOT standard</description>
<description>Specific BeeBOT standard</description>

<exclude-pattern>*/vendor/*</exclude-pattern>
<file>src</file>
<file>test</file>
<exclude-pattern>*/vendor/*</exclude-pattern>

<rule ref="PSR1"/>
<rule ref="PSR2"/>
<rule ref="PSR1"/>
<rule ref="PSR2"/>

<rule ref="Generic.CodeAnalysis.EmptyStatement" />
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />

<rule ref="Generic.ControlStructures.InlineControlStructure" />
<rule ref="Generic.ControlStructures.InlineControlStructure" />

<rule ref="Generic.Files.OneClassPerFile" />
<rule ref="Generic.Files.OneInterfacePerFile" />
<rule ref="Generic.Files.OneTraitPerFile" />
<rule ref="Generic.Files.EndFileNewline" />
<rule ref="Generic.Files.LineLength" />
<rule ref="Generic.Files.OneClassPerFile" />
<rule ref="Generic.Files.OneInterfacePerFile" />
<rule ref="Generic.Files.OneTraitPerFile" />
<rule ref="Generic.Files.EndFileNewline" />
<rule ref="Generic.Files.LineLength" />

<rule ref="Generic.NamingConventions.ConstructorName" />
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
<rule ref="Generic.NamingConventions.ConstructorName" />
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />

<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" />
<rule ref="Generic.PHP.DeprecatedFunctions" />
<rule ref="Generic.PHP.ForbiddenFunctions" />
<rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.PHP.NoSilencedErrors" />
<rule ref="Generic.PHP.SAPIUsage" />
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" />
<rule ref="Generic.PHP.DeprecatedFunctions" />
<rule ref="Generic.PHP.ForbiddenFunctions" />
<rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.PHP.NoSilencedErrors" />
<rule ref="Generic.PHP.SAPIUsage" />

<rule ref="Generic.Strings.UnnecessaryStringConcat" />
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>

<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
</ruleset>
27 changes: 0 additions & 27 deletions phpunit.xml.dist

This file was deleted.

10 changes: 0 additions & 10 deletions test/bootstrap.php

This file was deleted.

45 changes: 0 additions & 45 deletions test/units/AbstractAdapterTest.php

This file was deleted.

70 changes: 70 additions & 0 deletions test/units/Adapters/AbstractAdapterTest.php
@@ -0,0 +1,70 @@
<?php
/**
* This file is part of the bee4/events package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Bee4 2014
* @author Stephane HULARD <s.hulard@chstudio.fr>
*/

namespace Bee4\Events\Test\Units\Adapters;

/**
* Check behaviour of an adapter
*/
abstract class AbstractAdapterTest extends \atoum
{

protected $adapter;

public function testAdapter()
{
$this
->given(
$handler = function () {
echo "Youpi!";
},
$event = new \mock\Bee4\Events\EventInterface
)
->when($this->adapter->add('name', $handler))
->output(function () use ($event) {
$this->adapter->dispatch('name', $event);
})
->isEqualTo("Youpi!");
}

public function testAdd()
{
$this
->given($handler = function () {
echo "Youpi!";
})
->then
->array($this->adapter->get('name'))
->hasSize(0)
->when($this->adapter->add('name', $handler))
->then
->array($this->adapter->get('name'))
->hasSize(1);
}


public function testRemove()
{
$this
->given(
$handler = function () {
echo "Youpi!";
},
$this->adapter->add('name', $handler)
)
->then
->array($this->adapter->get('name'))
->hasSize(1)
->when($this->adapter->remove('name', $handler))
->then
->array($this->adapter->get('name'))
->hasSize(0);
}
}
26 changes: 26 additions & 0 deletions test/units/Adapters/EvenementEventEmitterAdapter.php
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of the bee4/events package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Bee4 2014
* @author Stephane HULARD <s.hulard@chstudio.fr>
*/

namespace Bee4\Events\Test\Units\Adapters;

use Bee4\Events\Adapters\EvenementEventEmitterAdapter as SUT;

/**
* Check behaviour Événement EventEmitter adapter
*/
class EvenementEventEmitterAdapter extends AbstractAdapterTest
{
public function beforeTestMethod($method)
{
$this->adapter = new SUT(
new \Evenement\EventEmitter()
);
}
}
26 changes: 26 additions & 0 deletions test/units/Adapters/SymfonyEventDispatcherAdapter.php
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of the bee4/events package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Bee4 2014
* @author Stephane HULARD <s.hulard@chstudio.fr>
*/

namespace Bee4\Events\Test\Units\Adapters;

use Bee4\Events\Adapters\SymfonyEventDispatcherAdapter as SUT;

/**
* Check behaviour SF2 EventDispatcher adapter
*/
class SymfonyEventDispatcherAdapter extends AbstractAdapterTest
{
public function beforeTestMethod($method)
{
$this->adapter = new SUT(
new \Symfony\Component\EventDispatcher\EventDispatcher()
);
}
}
26 changes: 26 additions & 0 deletions test/units/DispatcherAwareInterface.php
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of the bee4/events package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Bee4 2016
* @author Stephane HULARD <s.hulard@chstudio.fr>
*/

namespace Bee4\Events\Test\Units;

/**
* Check behaviour of the DispatcherAwareInterface
*/
class DispatcherAwareInterface extends \atoum
{
public function testInterface()
{
$this
->given($event = new \Mock\Bee4\Events\DispatcherAwareInterface)
->then
->object($event)
->isInstanceOf('Bee4\Events\DispatcherAwareInterface');
}
}

0 comments on commit 98dd0e4

Please sign in to comment.