forked from jadell/PHPBuiltinMock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuiltinMock_Function.php
53 lines (48 loc) · 1.49 KB
/
BuiltinMock_Function.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* Base class of builtin mocks
* Child classes must create the mock() function.
*/
abstract class BuiltinMock_Function
{
/**
* Name that can be used to call the original function being mocked
* @var string
*/
protected $sOriginal;
/////////////////////////////////////////////////////////////////////////////
// ABSTRACT ////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/**
* This defines the action that the mocked function will take when called.
*
* mock() methods should include the expected parameters in their
* docblocks, as usual.
*
* @param array $aArgs required=true
* @return mixed
*/
abstract public function mock($aArgs);
/////////////////////////////////////////////////////////////////////////////
// PUBLIC //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/**
* Method that calls the original function
*
* @param array $aArgs array of arguments to be passed to the function required=false
* @return mixed return of the original function
*/
public function callOriginal($aArgs=array())
{
return call_user_func_array($this->sOriginal, $aArgs);
}
/**
* Set the name that can be used to call the original function
*
* @param string $sOriginal required=true
*/
public function setOriginalName($sOriginal)
{
$this->sOriginal = $sOriginal;
}
}