1*78c63d53SAndreas Gohr<?php 2*78c63d53SAndreas Gohr 3*78c63d53SAndreas Gohr/** 4*78c63d53SAndreas Gohr * Tests for the validation functionality of the farmer plugin 5*78c63d53SAndreas Gohr * 6*78c63d53SAndreas Gohr * @group plugin_farmer 7*78c63d53SAndreas Gohr * @group plugins 8*78c63d53SAndreas Gohr */ 9*78c63d53SAndreas Gohrclass helper_plugin_farmer_test extends DokuWikiTest { 10*78c63d53SAndreas Gohr 11*78c63d53SAndreas Gohr protected $pluginsEnabled = array('farmer',); 12*78c63d53SAndreas Gohr 13*78c63d53SAndreas Gohr public function validationProvider() { 14*78c63d53SAndreas Gohr return array( 15*78c63d53SAndreas Gohr array('ant', true), 16*78c63d53SAndreas Gohr array('ant.lion', true), 17*78c63d53SAndreas Gohr array('ant.lion.cow', true), 18*78c63d53SAndreas Gohr array('ant-lion', true), 19*78c63d53SAndreas Gohr array('ant-lion.cow', true), 20*78c63d53SAndreas Gohr array('4ant', true), 21*78c63d53SAndreas Gohr array('ant4', true), 22*78c63d53SAndreas Gohr array('ant44lion', true), 23*78c63d53SAndreas Gohr array('44', true), 24*78c63d53SAndreas Gohr 25*78c63d53SAndreas Gohr array('ant.', false), 26*78c63d53SAndreas Gohr array('.ant', false), 27*78c63d53SAndreas Gohr array('ant-', false), 28*78c63d53SAndreas Gohr array('-ant', false), 29*78c63d53SAndreas Gohr array('ant--lion', false), 30*78c63d53SAndreas Gohr array('ant..lion', false), 31*78c63d53SAndreas Gohr array('ant.-lion', false), 32*78c63d53SAndreas Gohr array('ant/lion', false), 33*78c63d53SAndreas Gohr array('!ant', false), 34*78c63d53SAndreas Gohr array('ant lion', false), 35*78c63d53SAndreas Gohr ); 36*78c63d53SAndreas Gohr } 37*78c63d53SAndreas Gohr 38*78c63d53SAndreas Gohr /** 39*78c63d53SAndreas Gohr * @dataProvider validationProvider 40*78c63d53SAndreas Gohr * @param $input 41*78c63d53SAndreas Gohr * @param $expect 42*78c63d53SAndreas Gohr */ 43*78c63d53SAndreas Gohr public function test_validateAnimalName($input, $expect) { 44*78c63d53SAndreas Gohr /** @var helper_plugin_farmer $helper */ 45*78c63d53SAndreas Gohr $helper = plugin_load('helper', 'farmer'); 46*78c63d53SAndreas Gohr $this->assertEquals($expect, $helper->validateAnimalName($input)); 47*78c63d53SAndreas Gohr } 48*78c63d53SAndreas Gohr 49*78c63d53SAndreas Gohr public function test_isInPath() { 50*78c63d53SAndreas Gohr /** @var helper_plugin_farmer $helper */ 51*78c63d53SAndreas Gohr $helper = plugin_load('helper', 'farmer'); 52*78c63d53SAndreas Gohr 53*78c63d53SAndreas Gohr $this->assertTrue($helper->isInPath('/var/www/foo', '/var/www')); 54*78c63d53SAndreas Gohr $this->assertFalse($helper->isInPath('/var/www/../foo', '/var/www')); 55*78c63d53SAndreas Gohr 56*78c63d53SAndreas Gohr } 57*78c63d53SAndreas Gohr} 58