1<?php 2 3declare(strict_types=1); 4 5namespace dokuwiki\plugin\bookcreator\test; 6 7use Doku_Handler; 8use DokuWikiTest; 9use syntax_plugin_bookcreator_bookmanager; 10 11/** 12 * Tests for the syntax component of the bookcreator plugin 13 * 14 * @group plugin_bookcreator 15 * @group plugins 16 */ 17class SyntaxTest extends DokuWikiTest 18{ 19 20 public function syntaxProvider() { 21 return [ 22 'archive syntax with full normal details' => [ '~~ARCHIVEBOOK:5&date~~', [ 'archive', 5, 'date' ] ], 23 'archive syntax with full reversed details' => [ '~~ARCHIVEBOOK:title&7~~', [ 'archive', 7, 'title' ] ], 24 'archive syntax with count only' => [ '~~ARCHIVEBOOK:8~~', [ 'archive', 8, 'date' ] ], 25 'archive syntax with order only' => [ '~~ARCHIVEBOOK:title~~', [ 'archive', 10, 'title' ] ], 26 'archive syntax with defaults' => [ '~~ARCHIVEBOOK~~', [ 'archive', 10, 'date' ] ], 27 'archive syntax with full details but wrong ordername' => [ '~~ARCHIVEBOOK:5&unknownorder~~', [ 'archive', 5, 'date' ] ], 28 'archive syntax with full reversed details but wrong ordername' => [ '~~ARCHIVEBOOK:unknownorder&7~~', [ 'archive', 7, 'date' ] ], 29 'archive syntax with full details, zero count' => [ '~~ARCHIVEBOOK:date&0~~', [ 'archive', 0, 'date' ] ], 30 'bookmanager syntax' => [ '~~BOOK~~', [ 'bookmanager', 10, 'date' ] ], 31 ]; 32 } 33 34 /** 35 * @dataProvider syntaxProvider 36 */ 37 public function test_ArchiveSyntax($syntax, $expectedData) { 38 $dokuHandler = new Doku_Handler(); 39 $syntaxComponent = new syntax_plugin_bookcreator_bookmanager(); 40 41 $result = $syntaxComponent->handle( 42 $syntax, 43 5, 44 1, 45 $dokuHandler 46 ); 47 48 self::assertEquals( $expectedData, $result ); 49 } 50} 51