Hoa central
Public Member Functions | List of all members
Hoa\Ruler\Test\Unit\Context Class Reference
Inheritance diagram for Hoa\Ruler\Test\Unit\Context:

Public Member Functions

 case_array_access ()
 
 case_exists_set_get ()
 
 case_exception_when_getting_unspecified_key ()
 
 case_unset ()
 
 case_callable_closure ()
 
 case_callable_user_function ()
 
 case_callable_internal_function ()
 
 case_callable_method ()
 
 case_callable_xcallable ()
 
 case_callable_cache ()
 
 case_callable_no_cache ()
 
 case_callable_argument ()
 
 fakeCallable ()
 
- Public Member Functions inherited from Hoa\Test\Unit\Suite
 __construct ()
 
 getTestedClassName ()
 
 getTestedClassNamespace ()
 
 beforeTestMethod ($methodName)
 

Detailed Description

Class .

Test suite of the context.

Definition at line 51 of file Context.php.

Member Function Documentation

Hoa\Ruler\Test\Unit\Context::case_array_access ( )

Definition at line 53 of file Context.php.

54  {
55  $this
56  ->when($context = new CUT())
57  ->then
58  ->object($context)
59  ->isInstanceOf('ArrayAccess');
60  }
Hoa\Ruler\Test\Unit\Context::case_callable_argument ( )

Definition at line 228 of file Context.php.

229  {
230  $this
231  ->given(
232  $self = $this,
233  $context = new CUT(),
234  $context['foo'] = function () use ($self, $context) {
235  $arguments = func_get_args();
236 
237  $self
238  ->integer(count($arguments))
239  ->isEqualTo(1)
240  ->object($arguments[0])
241  ->isIdenticalTo($context);
242  }
243  )
244  ->when($result = $context['foo']);
245  }
Hoa\Ruler\Test\Unit\Context::case_callable_cache ( )

Definition at line 184 of file Context.php.

185  {
186  $this
187  ->given(
188  $context = new CUT(),
189  $context['foo'] = function () {
190  static $i = 0;
191 
192  return $i++;
193  }
194  )
195  ->when($result = $context['foo'])
196  ->then
197  ->integer($result)
198  ->isEqualTo(0)
199 
200  ->when($result = $context['foo'])
201  ->then
202  ->integer($result)
203  ->isEqualTo(0);
204  }
Hoa\Ruler\Test\Unit\Context::case_callable_closure ( )

Definition at line 117 of file Context.php.

118  {
119  $this
120  ->given(
121  $context = new CUT(),
122  $context['foo'] = function () {
123  return fakeCallable();
124  }
125  )
126  ->when($result = $context['foo'])
127  ->then
128  ->boolean($result)
129  ->isTrue();
130  }

Here is the call graph for this function:

Hoa\Ruler\Test\Unit\Context::case_callable_internal_function ( )

Definition at line 145 of file Context.php.

146  {
147  $this
148  ->given(
149  $context = new CUT(),
150  $context['foo'] = 'var_dump'
151  )
152  ->when($result = $context['foo'])
153  ->then
154  ->string($result)
155  ->isEqualTo('var_dump');
156  }
Hoa\Ruler\Test\Unit\Context::case_callable_method ( )

Definition at line 158 of file Context.php.

159  {
160  $this
161  ->given(
162  $context = new CUT(),
163  $context['foo'] = [$this, 'fakeCallable']
164  )
165  ->when($result = $context['foo'])
166  ->then
167  ->boolean($result)
168  ->isTrue();
169  }
Hoa\Ruler\Test\Unit\Context::case_callable_no_cache ( )

Definition at line 206 of file Context.php.

207  {
208  $this
209  ->given(
210  $context = new CUT(),
211  $context['foo'] = new LUT\DynamicCallable(function () {
212  static $i = 0;
213 
214  return $i++;
215  })
216  )
217  ->when($result = $context['foo'])
218  ->then
219  ->integer($result)
220  ->isEqualTo(0)
221 
222  ->when($result = $context['foo'])
223  ->then
224  ->integer($result)
225  ->isEqualTo(1);
226  }
Hoa\Ruler\Test\Unit\Context::case_callable_user_function ( )

Definition at line 132 of file Context.php.

133  {
134  $this
135  ->given(
136  $context = new CUT(),
137  $context['foo'] = __NAMESPACE__ . '\fakeCallable'
138  )
139  ->when($result = $context['foo'])
140  ->then
141  ->boolean($result)
142  ->isTrue();
143  }
Hoa\Ruler\Test\Unit\Context::case_callable_xcallable ( )

Definition at line 171 of file Context.php.

172  {
173  $this
174  ->given(
175  $context = new CUT(),
176  $context['foo'] = xcallable($this, 'fakeCallable')
177  )
178  ->when($result = $context['foo'])
179  ->then
180  ->boolean($result)
181  ->isTrue();
182  }
Hoa\Ruler\Test\Unit\Context::case_exception_when_getting_unspecified_key ( )

Definition at line 82 of file Context.php.

83  {
84  $this
85  ->given($context = new CUT())
86  ->exception(function () use ($context) {
87  $context['foo'];
88  })
89  ->isInstanceOf('Hoa\Ruler\Exception');
90  }
Hoa\Ruler\Test\Unit\Context::case_exists_set_get ( )

Definition at line 62 of file Context.php.

63  {
64  $this
65  ->given(
66  $key = 'foo',
67  $value = 'bar',
68  $context = new CUT()
69  )
70  ->then
71  ->boolean(isset($context[$key]))
72  ->isFalse()
73 
74  ->when($context[$key] = $value)
75  ->then
76  ->boolean(isset($context[$key]))
77  ->isTrue()
78  ->string($context[$key])
79  ->isEqualTo($value);
80  }
Hoa\Ruler\Test\Unit\Context::case_unset ( )

Definition at line 92 of file Context.php.

93  {
94  $this
95  ->given(
96  $key = 'foo',
97  $value = 'bar',
98  $context = new CUT()
99  )
100  ->then
101  ->boolean(isset($context[$key]))
102  ->isFalse()
103 
104  ->when($context[$key] = $value)
105  ->then
106  ->boolean(isset($context[$key]))
107  ->isTrue()
108 
109  ->when(function () use ($context, $key) {
110  unset($context[$key]);
111  })
112  ->then
113  ->boolean(isset($context[$key]))
114  ->isFalse();
115  }
Hoa\Ruler\Test\Unit\Context::fakeCallable ( )

Definition at line 247 of file Context.php.

248  {
249  return fakeCallable();
250  }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: