1*f4b4490fSAndreas Gohr<?php 2*f4b4490fSAndreas Gohr 3*f4b4490fSAndreas Gohrnamespace dokuwiki\plugin\config\test; 4*f4b4490fSAndreas Gohr 5*f4b4490fSAndreas Gohruse dokuwiki\HTTP\DokuHTTPClient; 6*f4b4490fSAndreas Gohruse dokuwiki\plugin\config\core\Configuration; 7*f4b4490fSAndreas Gohruse dokuwiki\plugin\config\core\Setting\SettingFieldset; 8*f4b4490fSAndreas Gohruse dokuwiki\plugin\config\core\Setting\SettingHidden; 9*f4b4490fSAndreas Gohr 10*f4b4490fSAndreas Gohr/** 11*f4b4490fSAndreas Gohr * Ensure config options have documentation at dokuwiki.org 12*f4b4490fSAndreas Gohr * 13*f4b4490fSAndreas Gohr * @group plugin_config 14*f4b4490fSAndreas Gohr * @group admin_plugins 15*f4b4490fSAndreas Gohr * @group plugins 16*f4b4490fSAndreas Gohr * @group bundled_plugins 17*f4b4490fSAndreas Gohr * @group internet 18*f4b4490fSAndreas Gohr */ 19*f4b4490fSAndreas Gohrclass DocumentationTest extends \DokuWikiTest 20*f4b4490fSAndreas Gohr{ 21*f4b4490fSAndreas Gohr /** 22*f4b4490fSAndreas Gohr * @return \Generator|array[] 23*f4b4490fSAndreas Gohr */ 24*f4b4490fSAndreas Gohr public function provideSettings() 25*f4b4490fSAndreas Gohr { 26*f4b4490fSAndreas Gohr $configuration = new Configuration(); 27*f4b4490fSAndreas Gohr 28*f4b4490fSAndreas Gohr foreach ($configuration->getSettings() as $setting) { 29*f4b4490fSAndreas Gohr if (is_a($setting, SettingHidden::class)) continue; 30*f4b4490fSAndreas Gohr if (is_a($setting, SettingFieldset::class)) continue; 31*f4b4490fSAndreas Gohr 32*f4b4490fSAndreas Gohr $key = $setting->getKey(); 33*f4b4490fSAndreas Gohr $pretty = $setting->getPrettyKey(); 34*f4b4490fSAndreas Gohr if (!preg_match('/ href="(.*?)"/', $pretty, $m)) continue; 35*f4b4490fSAndreas Gohr $url = $m[1]; 36*f4b4490fSAndreas Gohr 37*f4b4490fSAndreas Gohr yield [$key, $url]; 38*f4b4490fSAndreas Gohr } 39*f4b4490fSAndreas Gohr } 40*f4b4490fSAndreas Gohr 41*f4b4490fSAndreas Gohr /** 42*f4b4490fSAndreas Gohr * @dataProvider provideSettings 43*f4b4490fSAndreas Gohr * @param string $key Settingskey 44*f4b4490fSAndreas Gohr * @param string $url Documentation URL 45*f4b4490fSAndreas Gohr */ 46*f4b4490fSAndreas Gohr public function testDocs($key, $url) 47*f4b4490fSAndreas Gohr { 48*f4b4490fSAndreas Gohr $http = new DokuHTTPClient(); 49*f4b4490fSAndreas Gohr $check = $http->get($url); 50*f4b4490fSAndreas Gohr $fail = (bool)strpos($check, 'topic does not exist'); 51*f4b4490fSAndreas Gohr $msg = "Setting '$key' should have documentation at $url."; 52*f4b4490fSAndreas Gohr $this->assertFalse($fail, $msg . ' ' . $http->status . ' ' . $http->error); 53*f4b4490fSAndreas Gohr } 54*f4b4490fSAndreas Gohr} 55