1 : <?php
2 : /**
3 : * Mockery
4 : *
5 : * LICENSE
6 : *
7 : * This source file is subject to the new BSD license that is bundled
8 : * with this package in the file LICENSE.txt.
9 : * It is also available through the world-wide-web at this URL:
10 : * http://github.com/padraic/mockery/blob/master/LICENSE
11 : * If you did not receive a copy of the license and are unable to
12 : * obtain it through the world-wide-web, please send an email
13 : * to padraic@php.net so we can send you a copy immediately.
14 : *
15 : * @category Mockery
16 : * @package Mockery
17 : * @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
18 : * @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
19 : */
20 :
21 : namespace Mockery;
22 :
23 : class Configuration
24 : {
25 :
26 : /**
27 : * Boolean assertion of whether we can mock methods which do not actually
28 : * exist for the given class or object (ignored for unreal mocks)
29 : *
30 : * @var bool
31 : */
32 : protected $_allowMockingNonExistentMethod = true;
33 :
34 : /**
35 : * Boolean assertion of whether we ignore unnecessary mocking of methods,
36 : * i.e. when method expectations are made, set using a zeroOrMoreTimes()
37 : * constraint, and then never called. Essentially such expectations are
38 : * not required and are just taking up test space.
39 : *
40 : * @var bool
41 : */
42 : protected $_allowMockingMethodsUnnecessarily = true;
43 :
44 : /**
45 : * Parameter map for use with PHP internal classes.
46 : *
47 : * @var array
48 : */
49 : protected $_internalClassParamMap = array();
50 :
51 : /**
52 : * Set boolean to allow/prevent mocking of non-existent methods
53 : *
54 : * @param bool
55 : */
56 : public function allowMockingNonExistentMethods($flag = true)
57 : {
58 0 : $this->_allowMockingNonExistentMethod = (bool) $flag;
59 0 : }
60 :
61 : /**
62 : * Return flag indicating whether mocking non-existent methods allowed
63 : *
64 : * @return bool
65 : */
66 : public function mockingNonExistentMethodsAllowed()
67 : {
68 26 : return $this->_allowMockingNonExistentMethod;
69 : }
70 :
71 : /**
72 : * Set boolean to allow/prevent unnecessary mocking of methods
73 : *
74 : * @param bool
75 : */
76 : public function allowMockingMethodsUnnecessarily($flag = true)
77 : {
78 0 : $this->_allowMockingMethodsUnnecessarily = (bool) $flag;
79 0 : }
80 :
81 : /**
82 : * Return flag indicating whether mocking non-existent methods allowed
83 : *
84 : * @return bool
85 : */
86 : public function mockingMethodsUnnecessarilyAllowed()
87 : {
88 0 : return $this->_allowMockingMethodsUnnecessarily;
89 : }
90 :
91 : /**
92 : * Set a parameter map (array of param signature strings) for the method
93 : * of an internal PHP class.
94 : *
95 : * @param string $class
96 : * @param string $method
97 : * @param array $map
98 : */
99 : public function setInternalClassMethodParamMap($class, $method, array $map)
100 : {
101 0 : if (!isset($this->_internalClassParamMap[strtolower($class)])) {
102 0 : $this->_internalClassParamMap[strtolower($class)] = array();
103 0 : }
104 0 : $this->_internalClassParamMap[strtolower($class)][strtolower($method)] = $map;
105 0 : }
106 :
107 : /**
108 : * Get the parameter map of an internal PHP class method
109 : *
110 : * @return array
111 : */
112 : public function getInternalClassMethodParamMap($class, $method)
113 : {
114 0 : if (isset($this->_internalClassParamMap[strtolower($class)][strtolower($method)])) {
115 0 : return $this->_internalClassParamMap[strtolower($class)][strtolower($method)];
116 : }
117 0 : }
118 :
119 : }
|