88
99class AggregateResolverTest extends PHPUnit_Framework_TestCase
1010{
11+ public function setUp ()
12+ {
13+ require_once __DIR__ . '/../../_files/ResolverWithCollect.php ' ;
14+ }
15+
1116 public function testResolve ()
1217 {
1318 $ resolver = new AggregateResolver ();
@@ -46,9 +51,9 @@ public function testResolve()
4651
4752 public function testCollect ()
4853 {
49- $ resolver = new AggregateResolver ();
50-
51- $ lowPriority = $ this ->getMock ('AssetManager\Resolver\ResolverInterface ' );
54+ /* Tests for interfaces that _do_ implement the `collect` method. */
55+ $ resolver = new AggregateResolver ();
56+ $ lowPriority = $ this ->getMock ('ResolverWithCollect ' );
5257 $ lowPriority
5358 ->expects ($ this ->exactly (2 ))
5459 ->method ('collect ' )
@@ -57,7 +62,7 @@ public function testCollect()
5762
5863 $ this ->assertContains ('one ' , $ resolver ->collect ());
5964
60- $ highPriority = $ this ->getMock ('AssetManager\Resolver\ResolverInterface ' );
65+ $ highPriority = $ this ->getMock ('ResolverWithCollect ' );
6166 $ highPriority
6267 ->expects ($ this ->once ())
6368 ->method ('collect ' )
@@ -69,5 +74,21 @@ public function testCollect()
6974 $ this ->assertContains ('three ' , $ collection );
7075
7176 $ this ->assertCount (3 , $ collection );
77+
78+ /* Tests for interfaces that _don't_ implement the `collect` method. */
79+ $ resolver = new AggregateResolver ();
80+ $ lowPriority = $ this ->getMock ('AssetManager\Resolver\ResolverInterface ' );
81+
82+ $ resolver ->attach ($ lowPriority );
83+
84+ $ this ->assertEquals (array (), $ resolver ->collect ());
85+
86+ $ highPriority = $ this ->getMock ('AssetManager\Resolver\ResolverInterface ' );
87+ $ resolver ->attach ($ highPriority , 1000 );
88+
89+ $ collection = $ resolver ->collect ();
90+ $ this ->assertEquals (array (), $ collection );
91+
92+ $ this ->assertCount (0 , $ collection );
7293 }
7394}
0 commit comments