Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
27 / 36 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_extension_extension_base_test | |
75.00% |
27 / 36 |
|
50.00% |
2 / 4 |
4.25 | |
0.00% |
0 / 1 |
| setUpBeforeClass | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| setUp | |
100.00% |
23 / 23 |
|
100.00% |
1 / 1 |
1 | |||
| data_test_suffix_get_classes | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_suffix_get_classes | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 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 | require_once __DIR__ . '/ext/vendor2/bar/migrations/bar.php'; |
| 14 | require_once __DIR__ . '/ext/vendor2/bar/migrations/foo.php'; |
| 15 | require_once __DIR__ . '/ext/vendor2/bar/migrations/migration.php'; |
| 16 | |
| 17 | class phpbb_extension_extension_base_test extends phpbb_test_case |
| 18 | { |
| 19 | protected static $reflection_method_get_migration_file_list; |
| 20 | |
| 21 | /** @var phpbb_mock_extension_manager */ |
| 22 | protected $extension_manager; |
| 23 | |
| 24 | public static function setUpBeforeClass(): void |
| 25 | { |
| 26 | parent::setUpBeforeClass(); |
| 27 | |
| 28 | $reflection_class = new ReflectionClass('\phpbb\extension\base'); |
| 29 | self::$reflection_method_get_migration_file_list = $reflection_class->getMethod('get_migration_file_list'); |
| 30 | } |
| 31 | |
| 32 | protected function setUp(): void |
| 33 | { |
| 34 | $container = new phpbb_mock_container_builder(); |
| 35 | $migrator = new phpbb_mock_migrator(); |
| 36 | $container->set('migrator', $migrator); |
| 37 | |
| 38 | $this->extension_manager = new phpbb_mock_extension_manager( |
| 39 | __DIR__ . '/', |
| 40 | array( |
| 41 | 'vendor2/foo' => array( |
| 42 | 'ext_name' => 'vendor2/foo', |
| 43 | 'ext_active' => '1', |
| 44 | 'ext_path' => 'ext/vendor2/foo/', |
| 45 | ), |
| 46 | 'vendor3/bar' => array( |
| 47 | 'ext_name' => 'vendor3/bar', |
| 48 | 'ext_active' => '1', |
| 49 | 'ext_path' => 'ext/vendor3/bar/', |
| 50 | ), |
| 51 | 'vendor2/bar' => array( |
| 52 | 'ext_name' => 'vendor2/bar', |
| 53 | 'ext_active' => '1', |
| 54 | 'ext_path' => 'ext/vendor2/bar/', |
| 55 | ), |
| 56 | ), |
| 57 | $container); |
| 58 | } |
| 59 | |
| 60 | public static function data_test_suffix_get_classes() |
| 61 | { |
| 62 | return array( |
| 63 | array( |
| 64 | 'vendor2/bar', |
| 65 | array('\vendor2\bar\migrations\migration'), |
| 66 | ), |
| 67 | ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @dataProvider data_test_suffix_get_classes |
| 72 | */ |
| 73 | public function test_suffix_get_classes($extension_name, $expected) |
| 74 | { |
| 75 | $extension = $this->extension_manager->get_extension($extension_name); |
| 76 | $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension); |
| 77 | sort($migration_classes); |
| 78 | $this->assertEquals($expected, $migration_classes); |
| 79 | } |
| 80 | } |