1c66a21e9SMichael Große<?php 2c66a21e9SMichael Große 3*5b5c8486SAndreas Gohrnamespace plugin\farmer\test; 478c63d53SAndreas Gohr 5*5b5c8486SAndreas Gohrclass admin_plugin_farmer_new extends \admin_plugin_farmer_new 6*5b5c8486SAndreas Gohr{ 7*5b5c8486SAndreas Gohr public function getAdminLine() 8*5b5c8486SAndreas Gohr { 978c63d53SAndreas Gohr return parent::getAdminLine(); 1078c63d53SAndreas Gohr } 1178c63d53SAndreas Gohr 1278c63d53SAndreas Gohr} 1378c63d53SAndreas Gohr 14c66a21e9SMichael Große 15c66a21e9SMichael Große/** 16c66a21e9SMichael Große * Tests for the validation functionality of the farmer plugin 17c66a21e9SMichael Große * 18c66a21e9SMichael Große * @group plugin_farmer 19c66a21e9SMichael Große * @group plugins 20c66a21e9SMichael Große */ 21*5b5c8486SAndreas Gohrclass getUserLine_plugin_farmer_test extends \DokuWikiTest 22*5b5c8486SAndreas Gohr{ 23c66a21e9SMichael Große 24c66a21e9SMichael Große protected $pluginsEnabled = array('farmer',); 25c66a21e9SMichael Große private $usersfile; 26c66a21e9SMichael Große 27*5b5c8486SAndreas Gohr public function setUp(): void 28*5b5c8486SAndreas Gohr { 29c66a21e9SMichael Große parent::setUp(); 30c66a21e9SMichael Große $this->usersfile = DOKU_CONF . 'users.auth.php'; 31c66a21e9SMichael Große copy($this->usersfile, $this->usersfile . "org"); 32c66a21e9SMichael Große unlink($this->usersfile); 33c66a21e9SMichael Große } 34c66a21e9SMichael Große 35*5b5c8486SAndreas Gohr public function tearDown(): void 36*5b5c8486SAndreas Gohr { 37c66a21e9SMichael Große parent::tearDown(); 38c66a21e9SMichael Große unlink($this->usersfile); 39c66a21e9SMichael Große copy($this->usersfile . "org", $this->usersfile); 40c66a21e9SMichael Große unlink($this->usersfile . "org"); 41c66a21e9SMichael Große } 42c66a21e9SMichael Große 43c66a21e9SMichael Große 44*5b5c8486SAndreas Gohr public function test_getUserLine_oneUser() 45*5b5c8486SAndreas Gohr { 4678c63d53SAndreas Gohr $helper = new admin_plugin_farmer_new(); 47c66a21e9SMichael Große $usersfileData = "# users.auth.php 48c66a21e9SMichael Große# <?php exit()?> 49c66a21e9SMichael Große# Don't modify the lines above 50c66a21e9SMichael Große# 51c66a21e9SMichael Große# Userfile 52c66a21e9SMichael Große# 53c66a21e9SMichael Große# Format: 54c66a21e9SMichael Große# 55c66a21e9SMichael Große# user:MD5password:Real Name:email:groups,comma,seperated 56c66a21e9SMichael Große# 57c66a21e9SMichael Große# testuser : testpass 58c66a21e9SMichael Großetestuser:179ad45c6ce2cb97cf1029e212046e81:Arthur Dent:arthur@example.com:\n"; 59c66a21e9SMichael Große file_put_contents($this->usersfile, $usersfileData); 60c66a21e9SMichael Große 6178c63d53SAndreas Gohr $_SERVER['REMOTE_USER'] = 'testuser'; 62c66a21e9SMichael Große $expected_result = 'testuser:179ad45c6ce2cb97cf1029e212046e81:Arthur Dent:arthur@example.com:' . "\n"; 6378c63d53SAndreas Gohr $actual_result = $helper->getAdminLine(); 64c66a21e9SMichael Große 65c66a21e9SMichael Große $this->assertSame($expected_result, $actual_result); 66c66a21e9SMichael Große } 67c66a21e9SMichael Große 68*5b5c8486SAndreas Gohr public function test_getUserLine_manyUser() 69*5b5c8486SAndreas Gohr { 7078c63d53SAndreas Gohr $helper = new admin_plugin_farmer_new(); 71c66a21e9SMichael Große $usersfileData = "# users.auth.php 72c66a21e9SMichael Große# <?php exit()?> 73c66a21e9SMichael Große# Don't modify the lines above 74c66a21e9SMichael Große# 75c66a21e9SMichael Große# Userfile 76c66a21e9SMichael Große# 77c66a21e9SMichael Große# Format: 78c66a21e9SMichael Große# 79c66a21e9SMichael Große# user:MD5password:Real Name:email:groups,comma,seperated 80c66a21e9SMichael Große# 81c66a21e9SMichael Große# testuser : testpass 82c66a21e9SMichael Große1testuser:179ad45c6ce43897cf1029e212046e81:Arthur Dent:brthur@example.com:admin 83c66a21e9SMichael Großetestuser:179ad45c6ce2cb97cf1029e212046e81:Arthur Dent:arthur@example.com: 84c66a21e9SMichael Große2testuser:179ad45c6ce2cb97cf10214712046e81:Arthur inDent:crthur@example.com:admin\n"; 85c66a21e9SMichael Große file_put_contents($this->usersfile, $usersfileData); 86c66a21e9SMichael Große 8778c63d53SAndreas Gohr $_SERVER['REMOTE_USER'] = 'testuser'; 88c66a21e9SMichael Große $expected_result = 'testuser:179ad45c6ce2cb97cf1029e212046e81:Arthur Dent:arthur@example.com:' . "\n"; 8978c63d53SAndreas Gohr $actual_result = $helper->getAdminLine(); 90c66a21e9SMichael Große 91c66a21e9SMichael Große $this->assertSame($expected_result, $actual_result); 92c66a21e9SMichael Große } 93c66a21e9SMichael Große} 94