178c63d53SAndreas Gohr<?php 278c63d53SAndreas Gohr 378c63d53SAndreas Gohr/** 478c63d53SAndreas Gohr * Tests for the validation functionality of the farmer plugin 578c63d53SAndreas Gohr * 678c63d53SAndreas Gohr * @group plugin_farmer 778c63d53SAndreas Gohr * @group plugins 878c63d53SAndreas Gohr */ 978c63d53SAndreas Gohrclass helper_plugin_farmer_test extends DokuWikiTest { 1078c63d53SAndreas Gohr 1178c63d53SAndreas Gohr protected $pluginsEnabled = array('farmer',); 1278c63d53SAndreas Gohr 1378c63d53SAndreas Gohr public function validationProvider() { 1478c63d53SAndreas Gohr return array( 1578c63d53SAndreas Gohr array('ant', true), 1678c63d53SAndreas Gohr array('ant.lion', true), 1778c63d53SAndreas Gohr array('ant.lion.cow', true), 1878c63d53SAndreas Gohr array('ant-lion', true), 1978c63d53SAndreas Gohr array('ant-lion.cow', true), 2078c63d53SAndreas Gohr array('4ant', true), 2178c63d53SAndreas Gohr array('ant4', true), 2278c63d53SAndreas Gohr array('ant44lion', true), 2378c63d53SAndreas Gohr array('44', true), 2478c63d53SAndreas Gohr 2578c63d53SAndreas Gohr array('ant.', false), 2678c63d53SAndreas Gohr array('.ant', false), 2778c63d53SAndreas Gohr array('ant-', false), 2878c63d53SAndreas Gohr array('-ant', false), 2978c63d53SAndreas Gohr array('ant--lion', false), 3078c63d53SAndreas Gohr array('ant..lion', false), 3178c63d53SAndreas Gohr array('ant.-lion', false), 3278c63d53SAndreas Gohr array('ant/lion', false), 3378c63d53SAndreas Gohr array('!ant', false), 3478c63d53SAndreas Gohr array('ant lion', false), 3578c63d53SAndreas Gohr ); 3678c63d53SAndreas Gohr } 3778c63d53SAndreas Gohr 3878c63d53SAndreas Gohr /** 3978c63d53SAndreas Gohr * @dataProvider validationProvider 4078c63d53SAndreas Gohr * @param $input 4178c63d53SAndreas Gohr * @param $expect 4278c63d53SAndreas Gohr */ 4378c63d53SAndreas Gohr public function test_validateAnimalName($input, $expect) { 4478c63d53SAndreas Gohr /** @var helper_plugin_farmer $helper */ 4578c63d53SAndreas Gohr $helper = plugin_load('helper', 'farmer'); 4678c63d53SAndreas Gohr $this->assertEquals($expect, $helper->validateAnimalName($input)); 4778c63d53SAndreas Gohr } 4878c63d53SAndreas Gohr 4978c63d53SAndreas Gohr public function test_isInPath() { 5078c63d53SAndreas Gohr /** @var helper_plugin_farmer $helper */ 5178c63d53SAndreas Gohr $helper = plugin_load('helper', 'farmer'); 5278c63d53SAndreas Gohr 5378c63d53SAndreas Gohr $this->assertTrue($helper->isInPath('/var/www/foo', '/var/www')); 5478c63d53SAndreas Gohr $this->assertFalse($helper->isInPath('/var/www/../foo', '/var/www')); 5578c63d53SAndreas Gohr 56*dfdaf33eSAndreas Gohr // same dir should return false, too 57*dfdaf33eSAndreas Gohr $this->assertFalse($helper->isInPath('/var/www/foo', '/var/www/foo')); 58*dfdaf33eSAndreas Gohr $this->assertFalse($helper->isInPath('/var/www/foo/', '/var/www/foo')); 59*dfdaf33eSAndreas Gohr $this->assertFalse($helper->isInPath('/var/www/foo/bar/../', '/var/www/foo')); 6078c63d53SAndreas Gohr } 6178c63d53SAndreas Gohr} 62