PHP7 Strategy

This commit is contained in:
Dominik Liebler
2016-09-22 11:02:03 +02:00
parent 9b9eee5a4c
commit 36f3df8fbb
5 changed files with 47 additions and 53 deletions

View File

@@ -5,43 +5,42 @@ namespace DesignPatterns\Behavioral\Strategy\Tests;
use DesignPatterns\Behavioral\Strategy\DateComparator;
use DesignPatterns\Behavioral\Strategy\IdComparator;
use DesignPatterns\Behavioral\Strategy\ObjectCollection;
use DesignPatterns\Behavioral\Strategy\Strategy;
/**
* Tests for Strategy pattern.
*/
class StrategyTest extends \PHPUnit_Framework_TestCase
{
public function getIdCollection()
public function provideIntegers()
{
return array(
array(
array(array('id' => 2), array('id' => 1), array('id' => 3)),
array('id' => 1),
),
array(
array(array('id' => 3), array('id' => 2), array('id' => 1)),
array('id' => 1),
),
);
return [
[
[['id' => 2], ['id' => 1], ['id' => 3]],
['id' => 1],
],
[
[['id' => 3], ['id' => 2], ['id' => 1]],
['id' => 1],
],
];
}
public function getDateCollection()
public function providateDates()
{
return array(
array(
array(array('date' => '2014-03-03'), array('date' => '2015-03-02'), array('date' => '2013-03-01')),
array('date' => '2013-03-01'),
),
array(
array(array('date' => '2014-02-03'), array('date' => '2013-02-01'), array('date' => '2015-02-02')),
array('date' => '2013-02-01'),
),
);
return [
[
[['date' => '2014-03-03'], ['date' => '2015-03-02'], ['date' => '2013-03-01']],
['date' => '2013-03-01'],
],
[
[['date' => '2014-02-03'], ['date' => '2013-02-01'], ['date' => '2015-02-02']],
['date' => '2013-02-01'],
],
];
}
/**
* @dataProvider getIdCollection
* @dataProvider provideIntegers
*
* @param array $collection
* @param array $expected
*/
public function testIdComparator($collection, $expected)
{
@@ -54,7 +53,10 @@ class StrategyTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider getDateCollection
* @dataProvider providateDates
*
* @param array $collection
* @param array $expected
*/
public function testDateComparator($collection, $expected)
{