Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_ordered_service_collection_test | |
100.00% |
16 / 16 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
| test_service_collection | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | class phpbb_ordered_service_collection_test extends \phpbb_test_case |
| 15 | { |
| 16 | /** |
| 17 | * @var \phpbb\di\ordered_service_collection |
| 18 | */ |
| 19 | protected $service_collection; |
| 20 | |
| 21 | protected function setUp(): void |
| 22 | { |
| 23 | $container = new phpbb_mock_container_builder(); |
| 24 | $container->set('foo', new StdClass); |
| 25 | $container->set('bar', new StdClass); |
| 26 | $container->set('foobar', new StdClass); |
| 27 | $container->set('barfoo', new StdClass); |
| 28 | |
| 29 | $this->service_collection = new \phpbb\di\ordered_service_collection($container); |
| 30 | $this->service_collection->add('foo', 7); |
| 31 | $this->service_collection->add('bar', 3); |
| 32 | $this->service_collection->add('barfoo', 5); |
| 33 | $this->service_collection->add('foobar', 2); |
| 34 | |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function test_service_collection() |
| 39 | { |
| 40 | $service_names = array(); |
| 41 | |
| 42 | // Test the iterator |
| 43 | foreach ($this->service_collection as $name => $service) |
| 44 | { |
| 45 | $service_names[] = $name; |
| 46 | $this->assertInstanceOf('StdClass', $service); |
| 47 | } |
| 48 | |
| 49 | $this->assertSame(array('foobar', 'bar', 'barfoo', 'foo'), $service_names); |
| 50 | } |
| 51 | } |