TestCore.php 2.59 KB
Newer Older
Luke081515's avatar
Luke081515 committed
1 2
<?php
require_once __DIR__ . '/BotCore.php';
Luke081515's avatar
Luke081515 committed
3 4 5 6 7
/** TestCore.php
* Allows using Cygnus for testing
* @Author Luke081515 <luke081515@tools.wmflabs.org>
* @Version 1.0
* @Status Beta
Luke081515's avatar
Luke081515 committed
8 9
*/
class TestCore extends Core {
Luke081515's avatar
Luke081515 committed
10 11 12 13 14 15 16 17
	/** __construct
	* @param $loginData (Array)
	* $loginData[1] - the site to use
	* $loginData[2] - the username to use
	* $loginData[3] - the password to use
	* $loginData[0] is ignored, since this program is mostly for args
	** args[0] is the program name, so useless here
	*/
Luke081515's avatar
Luke081515 committed
18 19 20 21
	public function __construct($loginData) {
		$this->setSite($loginData[1]);
		$this->setUsername($loginData[2]);
		$this->setPassword($loginData[3]);
Luke081515's avatar
Luke081515 committed
22
		$this->initcurlArgs('TestCore', true, "bot", true);
Luke081515's avatar
Luke081515 committed
23 24
		$this->login();
	}
Luke081515's avatar
Luke081515 committed
25 26 27 28 29 30 31 32
	/** execute
	* @param - $functionData Array
	** $functionData[0] is the name of the function to execute
	** $functionData - all following values are the params
	** Takes up to 10 parameters
	* @Author Luke081515
	* @returns the return value of the Cygnus function
	*/
Luke081515's avatar
Luke081515 committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
	public function execute($functionData) {
		$functionName = $functionData[0];
		switch(count($functionData)) {
			case 1:
				return $this->$functionName();
			case 2:
				return $this->$functionName($functionData[1]);
			case 3:
				return $this->$functionName($functionData[1], $functionData[2]);
			case 4:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3]);
			case 5:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4]);
			case 6:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4],
					$functionData[5]);
			case 7:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4],
					$functionData[5], $functionData[6]);
			case 8:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4],
					$functionData[5], $functionData[6], $functionData[7]);
			case 9:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4],
					$functionData[5], $functionData[6], $functionData[7], $functionData[8]);
			case 10:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4],
					$functionData[5], $functionData[6], $functionData[7], $functionData[8], $functionData[9]);
			case 11:
				return $this->$functionName($functionData[1], $functionData[2], $functionData[3], $functionData[4],
					$functionData[5], $functionData[6], $functionData[7], $functionData[8], $functionData[9],
					$functionData[10]);
			default:
				return null;
		}
	}
}
?>