|
14 | 14 | // You should have received a copy of the GNU General Public License
|
15 | 15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
17 |
| -/** |
18 |
| - * Tests for the dataformat plugins |
19 |
| - * |
20 |
| - * @package core |
21 |
| - * @copyright 2020 Paul Holden <[email protected]> |
22 |
| - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
23 |
| - */ |
24 |
| - |
25 | 17 | namespace core;
|
26 | 18 |
|
| 19 | +use coding_exception; |
27 | 20 | use context_system;
|
28 | 21 | use core_component;
|
29 | 22 |
|
30 | 23 | /**
|
31 |
| - * Dataformat tests |
| 24 | + * Tests for the dataformat plugins |
32 | 25 | *
|
33 | 26 | * @package core
|
34 | 27 | * @covers \core\dataformat
|
35 | 28 | * @copyright 2020 Paul Holden <[email protected]>
|
36 | 29 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
37 | 30 | */
|
38 |
| -class dataformat_test extends \advanced_testcase { |
| 31 | +final class dataformat_test extends \advanced_testcase { |
| 32 | + |
| 33 | + /** |
| 34 | + * Test getting writer instance for given dataformat |
| 35 | + */ |
| 36 | + public function test_get_format_instance(): void { |
| 37 | + $instance = dataformat::get_format_instance('pdf'); |
| 38 | + $this->assertInstanceOf(\dataformat_pdf\writer::class, $instance); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Test getting writer instance for invalid dataformat |
| 43 | + */ |
| 44 | + public function test_get_format_instance_invalid(): void { |
| 45 | + $this->expectException(coding_exception::class); |
| 46 | + $this->expectExceptionMessage('Invalid dataformat (weird)'); |
| 47 | + dataformat::get_format_instance('weird'); |
| 48 | + } |
39 | 49 |
|
40 | 50 | /**
|
41 | 51 | * Data provider to return array of dataformat types
|
42 | 52 | *
|
43 | 53 | * @return array
|
44 | 54 | */
|
45 |
| - public function write_data_provider(): array { |
| 55 | + public static function write_data_provider(): array { |
46 | 56 | $data = [];
|
47 | 57 |
|
48 | 58 | $dataformats = core_component::get_plugin_list('dataformat');
|
|
0 commit comments