1*fe58309eSAndreas Gohr<?php 2*fe58309eSAndreas Gohr 3*fe58309eSAndreas Gohrnamespace dokuwiki\plugin\extension\test; 4*fe58309eSAndreas Gohr 5*fe58309eSAndreas Gohruse dokuwiki\plugin\extension\Extension; 6*fe58309eSAndreas Gohruse dokuwiki\plugin\extension\Notice; 7*fe58309eSAndreas Gohruse DokuWikiTest; 8*fe58309eSAndreas Gohr 9*fe58309eSAndreas Gohr/** 10*fe58309eSAndreas Gohr * Tests for the notice generation of the extension plugin 11*fe58309eSAndreas Gohr * 12*fe58309eSAndreas Gohr * @group plugin_extension 13*fe58309eSAndreas Gohr * @group plugins 14*fe58309eSAndreas Gohr */ 15*fe58309eSAndreas Gohrclass NoticeTest extends DokuWikiTest 16*fe58309eSAndreas Gohr{ 17*fe58309eSAndreas Gohr protected $pluginsEnabled = ['extension']; 18*fe58309eSAndreas Gohr 19*fe58309eSAndreas Gohr /** 20*fe58309eSAndreas Gohr * A malformed conflict id in the repository metadata must not crash the notice generation 21*fe58309eSAndreas Gohr * 22*fe58309eSAndreas Gohr * Extension authors may enter free form text like "sprintdoc template" in the conflicts 23*fe58309eSAndreas Gohr * field. Such values are not valid extension ids and must be skipped silently. 24*fe58309eSAndreas Gohr */ 25*fe58309eSAndreas Gohr public function testMalformedConflictIsIgnored() 26*fe58309eSAndreas Gohr { 27*fe58309eSAndreas Gohr $extension = Extension::createFromRemoteData([ 28*fe58309eSAndreas Gohr 'plugin' => 'plugin1', 29*fe58309eSAndreas Gohr 'conflicts' => ['sprintdoc template'], 30*fe58309eSAndreas Gohr ]); 31*fe58309eSAndreas Gohr 32*fe58309eSAndreas Gohr $notices = Notice::list($extension); 33*fe58309eSAndreas Gohr 34*fe58309eSAndreas Gohr $this->assertIsArray($notices); 35*fe58309eSAndreas Gohr $this->assertEmpty($notices[Notice::WARNING]); 36*fe58309eSAndreas Gohr } 37*fe58309eSAndreas Gohr 38*fe58309eSAndreas Gohr /** 39*fe58309eSAndreas Gohr * A malformed dependency id in the repository metadata must not crash the notice generation 40*fe58309eSAndreas Gohr */ 41*fe58309eSAndreas Gohr public function testMalformedDependencyIsIgnored() 42*fe58309eSAndreas Gohr { 43*fe58309eSAndreas Gohr // the extension plugin itself is installed, so the dependency check is not skipped 44*fe58309eSAndreas Gohr $extension = Extension::createFromRemoteData([ 45*fe58309eSAndreas Gohr 'plugin' => 'extension', 46*fe58309eSAndreas Gohr 'depends' => ['not:a:valid:id'], 47*fe58309eSAndreas Gohr ]); 48*fe58309eSAndreas Gohr 49*fe58309eSAndreas Gohr $notices = Notice::list($extension); 50*fe58309eSAndreas Gohr 51*fe58309eSAndreas Gohr $this->assertIsArray($notices); 52*fe58309eSAndreas Gohr $this->assertEmpty($notices[Notice::ERROR]); 53*fe58309eSAndreas Gohr } 54*fe58309eSAndreas Gohr} 55