2
2
3
3
namespace DesignPatterns \Behavioral \Strategy \Tests ;
4
4
5
+ use DesignPatterns \Behavioral \Strategy \Context ;
5
6
use DesignPatterns \Behavioral \Strategy \DateComparator ;
6
7
use DesignPatterns \Behavioral \Strategy \IdComparator ;
7
- use DesignPatterns \Behavioral \Strategy \ObjectCollection ;
8
8
use PHPUnit \Framework \TestCase ;
9
9
10
10
class StrategyTest extends TestCase
@@ -45,9 +45,8 @@ public function provideDates()
45
45
*/
46
46
public function testIdComparator ($ collection , $ expected )
47
47
{
48
- $ obj = new ObjectCollection ($ collection );
49
- $ obj ->setComparator (new IdComparator ());
50
- $ elements = $ obj ->sort ();
48
+ $ obj = new Context (new IdComparator ());
49
+ $ elements = $ obj ->executeStrategy ($ collection );
51
50
52
51
$ firstElement = array_shift ($ elements );
53
52
$ this ->assertEquals ($ expected , $ firstElement );
@@ -61,9 +60,8 @@ public function testIdComparator($collection, $expected)
61
60
*/
62
61
public function testDateComparator ($ collection , $ expected )
63
62
{
64
- $ obj = new ObjectCollection ($ collection );
65
- $ obj ->setComparator (new DateComparator ());
66
- $ elements = $ obj ->sort ();
63
+ $ obj = new Context (new DateComparator ());
64
+ $ elements = $ obj ->executeStrategy ($ collection );
67
65
68
66
$ firstElement = array_shift ($ elements );
69
67
$ this ->assertEquals ($ expected , $ firstElement );
0 commit comments