ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Pimple\Tests\PimpleTest Class Reference
+ Inheritance diagram for Pimple\Tests\PimpleTest:
+ Collaboration diagram for Pimple\Tests\PimpleTest:

Public Member Functions

 testWithString ()
 
 testWithClosure ()
 
 testServicesShouldBeDifferent ()
 
 testShouldPassContainerAsParameter ()
 
 testIsset ()
 
 testConstructorInjection ()
 
 testOffsetGetValidatesKeyIsPresent ()
 Identifier "foo" is not defined. More...
 
 testOffsetGetHonorsNullValues ()
 
 testUnset ()
 
 testShare ($service)
 serviceDefinitionProvider More...
 
 testProtect ($service)
 serviceDefinitionProvider More...
 
 testGlobalFunctionNameAsParameterValue ()
 
 testRaw ()
 
 testRawHonorsNullValues ()
 
 testFluentRegister ()
 
 testRawValidatesKeyIsPresent ()
 Identifier "foo" is not defined. More...
 
 testExtend ($service)
 serviceDefinitionProvider More...
 
 testExtendDoesNotLeakWithFactories ()
 
 testExtendValidatesKeyIsPresent ()
 Identifier "foo" is not defined. More...
 
 testKeys ()
 
 settingAnInvokableObjectShouldTreatItAsFactory ()
 
 settingNonInvokableObjectShouldTreatItAsParameter ()
 
 testFactoryFailsForInvalidServiceDefinitions ($service)
 badServiceDefinitionProvider Service definition is not a Closure or invokable object. More...
 
 testProtectFailsForInvalidServiceDefinitions ($service)
 badServiceDefinitionProvider Callable is not a Closure or invokable object. More...
 
 testExtendFailsForKeysNotContainingServiceDefinitions ($service)
 badServiceDefinitionProvider Identifier "foo" does not contain an object definition. More...
 
 testExtendFailsForInvalidServiceDefinitions ($service)
 badServiceDefinitionProvider Extension service definition is not a Closure or invokable object. More...
 
 badServiceDefinitionProvider ()
 Provider for invalid service definitions. More...
 
 serviceDefinitionProvider ()
 Provider for service definitions. More...
 
 testDefiningNewServiceAfterFreeze ()
 
 testOverridingServiceAfterFreeze ()
 Cannot override frozen service "foo". More...
 
 testRemovingServiceAfterFreeze ()
 
 testExtendingService ()
 
 testExtendingServiceAfterOtherServiceFreeze ()
 

Detailed Description

Author
Igor Wiedler igor@.nosp@m.wied.nosp@m.ler.c.nosp@m.h

Definition at line 34 of file PimpleTest.php.

Member Function Documentation

◆ badServiceDefinitionProvider()

Pimple\Tests\PimpleTest::badServiceDefinitionProvider ( )

Provider for invalid service definitions.

Definition at line 339 of file PimpleTest.php.

340  {
341  return array(
342  array(123),
343  array(new Fixtures\NonInvokable()),
344  );
345  }

◆ serviceDefinitionProvider()

Pimple\Tests\PimpleTest::serviceDefinitionProvider ( )

Provider for service definitions.

Definition at line 350 of file PimpleTest.php.

351  {
352  return array(
353  array(function ($value) {
354  $service = new Fixtures\Service();
355  $service->value = $value;
356 
357  return $service;
358  }),
359  array(new Fixtures\Invokable()),
360  );
361  }

◆ settingAnInvokableObjectShouldTreatItAsFactory()

Pimple\Tests\PimpleTest::settingAnInvokableObjectShouldTreatItAsFactory ( )
Test:

Definition at line 273 of file PimpleTest.php.

274  {
275  $pimple = new Container();
276  $pimple['invokable'] = new Fixtures\Invokable();
277 
278  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['invokable']);
279  }

◆ settingNonInvokableObjectShouldTreatItAsParameter()

Pimple\Tests\PimpleTest::settingNonInvokableObjectShouldTreatItAsParameter ( )
Test:

Definition at line 282 of file PimpleTest.php.

283  {
284  $pimple = new Container();
285  $pimple['non_invokable'] = new Fixtures\NonInvokable();
286 
287  $this->assertInstanceOf('Pimple\Tests\Fixtures\NonInvokable', $pimple['non_invokable']);
288  }

◆ testConstructorInjection()

Pimple\Tests\PimpleTest::testConstructorInjection ( )

Definition at line 100 of file PimpleTest.php.

References PHPMailer\PHPMailer\$params.

101  {
102  $params = array('param' => 'value');
103  $pimple = new Container($params);
104 
105  $this->assertSame($params['param'], $pimple['param']);
106  }

◆ testDefiningNewServiceAfterFreeze()

Pimple\Tests\PimpleTest::testDefiningNewServiceAfterFreeze ( )

Definition at line 363 of file PimpleTest.php.

364  {
365  $pimple = new Container();
366  $pimple['foo'] = function () {
367  return 'foo';
368  };
369  $foo = $pimple['foo'];
370 
371  $pimple['bar'] = function () {
372  return 'bar';
373  };
374  $this->assertSame('bar', $pimple['bar']);
375  }

◆ testExtend()

Pimple\Tests\PimpleTest::testExtend (   $service)

serviceDefinitionProvider

Definition at line 206 of file PimpleTest.php.

207  {
208  $pimple = new Container();
209  $pimple['shared_service'] = function () {
210  return new Fixtures\Service();
211  };
212  $pimple['factory_service'] = $pimple->factory(function () {
213  return new Fixtures\Service();
214  });
215 
216  $pimple->extend('shared_service', $service);
217  $serviceOne = $pimple['shared_service'];
218  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
219  $serviceTwo = $pimple['shared_service'];
220  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
221  $this->assertSame($serviceOne, $serviceTwo);
222  $this->assertSame($serviceOne->value, $serviceTwo->value);
223 
224  $pimple->extend('factory_service', $service);
225  $serviceOne = $pimple['factory_service'];
226  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
227  $serviceTwo = $pimple['factory_service'];
228  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
229  $this->assertNotSame($serviceOne, $serviceTwo);
230  $this->assertNotSame($serviceOne->value, $serviceTwo->value);
231  }

◆ testExtendDoesNotLeakWithFactories()

Pimple\Tests\PimpleTest::testExtendDoesNotLeakWithFactories ( )

Definition at line 233 of file PimpleTest.php.

234  {
235  if (extension_loaded('pimple')) {
236  $this->markTestSkipped('Pimple extension does not support this test');
237  }
238  $pimple = new Container();
239 
240  $pimple['foo'] = $pimple->factory(function () { return; });
241  $pimple['foo'] = $pimple->extend('foo', function ($foo, $pimple) { return; });
242  unset($pimple['foo']);
243 
244  $p = new \ReflectionProperty($pimple, 'values');
245  $p->setAccessible(true);
246  $this->assertEmpty($p->getValue($pimple));
247 
248  $p = new \ReflectionProperty($pimple, 'factories');
249  $p->setAccessible(true);
250  $this->assertCount(0, $p->getValue($pimple));
251  }

◆ testExtendFailsForInvalidServiceDefinitions()

Pimple\Tests\PimpleTest::testExtendFailsForInvalidServiceDefinitions (   $service)

badServiceDefinitionProvider Extension service definition is not a Closure or invokable object.

Definition at line 329 of file PimpleTest.php.

330  {
331  $pimple = new Container();
332  $pimple['foo'] = function () {};
333  $pimple->extend('foo', $service);
334  }

◆ testExtendFailsForKeysNotContainingServiceDefinitions()

Pimple\Tests\PimpleTest::testExtendFailsForKeysNotContainingServiceDefinitions (   $service)

badServiceDefinitionProvider Identifier "foo" does not contain an object definition.

Definition at line 317 of file PimpleTest.php.

318  {
319  $pimple = new Container();
320  $pimple['foo'] = $service;
321  $pimple->extend('foo', function () {});
322  }

◆ testExtendingService()

Pimple\Tests\PimpleTest::testExtendingService ( )

Definition at line 409 of file PimpleTest.php.

410  {
411  $pimple = new Container();
412  $pimple['foo'] = function () {
413  return 'foo';
414  };
415  $pimple['foo'] = $pimple->extend('foo', function ($foo, $app) {
416  return "$foo.bar";
417  });
418  $pimple['foo'] = $pimple->extend('foo', function ($foo, $app) {
419  return "$foo.baz";
420  });
421  $this->assertSame('foo.bar.baz', $pimple['foo']);
422  }

◆ testExtendingServiceAfterOtherServiceFreeze()

Pimple\Tests\PimpleTest::testExtendingServiceAfterOtherServiceFreeze ( )

Definition at line 424 of file PimpleTest.php.

425  {
426  $pimple = new Container();
427  $pimple['foo'] = function () {
428  return 'foo';
429  };
430  $pimple['bar'] = function () {
431  return 'bar';
432  };
433  $foo = $pimple['foo'];
434 
435  $pimple['bar'] = $pimple->extend('bar', function ($bar, $app) {
436  return "$bar.baz";
437  });
438  $this->assertSame('bar.baz', $pimple['bar']);
439  }

◆ testExtendValidatesKeyIsPresent()

Pimple\Tests\PimpleTest::testExtendValidatesKeyIsPresent ( )

Identifier "foo" is not defined.

Definition at line 257 of file PimpleTest.php.

258  {
259  $pimple = new Container();
260  $pimple->extend('foo', function () {});
261  }

◆ testFactoryFailsForInvalidServiceDefinitions()

Pimple\Tests\PimpleTest::testFactoryFailsForInvalidServiceDefinitions (   $service)

badServiceDefinitionProvider Service definition is not a Closure or invokable object.

Definition at line 295 of file PimpleTest.php.

296  {
297  $pimple = new Container();
298  $pimple->factory($service);
299  }

◆ testFluentRegister()

Pimple\Tests\PimpleTest::testFluentRegister ( )

Definition at line 187 of file PimpleTest.php.

188  {
189  $pimple = new Container();
190  $this->assertSame($pimple, $pimple->register($this->getMock('Pimple\ServiceProviderInterface')));
191  }

◆ testGlobalFunctionNameAsParameterValue()

Pimple\Tests\PimpleTest::testGlobalFunctionNameAsParameterValue ( )

Definition at line 166 of file PimpleTest.php.

167  {
168  $pimple = new Container();
169  $pimple['global_function'] = 'strlen';
170  $this->assertSame('strlen', $pimple['global_function']);
171  }

◆ testIsset()

Pimple\Tests\PimpleTest::testIsset ( )

Definition at line 84 of file PimpleTest.php.

85  {
86  $pimple = new Container();
87  $pimple['param'] = 'value';
88  $pimple['service'] = function () {
89  return new Fixtures\Service();
90  };
91 
92  $pimple['null'] = null;
93 
94  $this->assertTrue(isset($pimple['param']));
95  $this->assertTrue(isset($pimple['service']));
96  $this->assertTrue(isset($pimple['null']));
97  $this->assertFalse(isset($pimple['non_existent']));
98  }

◆ testKeys()

Pimple\Tests\PimpleTest::testKeys ( )

Definition at line 263 of file PimpleTest.php.

264  {
265  $pimple = new Container();
266  $pimple['foo'] = 123;
267  $pimple['bar'] = 123;
268 
269  $this->assertEquals(array('foo', 'bar'), $pimple->keys());
270  }

◆ testOffsetGetHonorsNullValues()

Pimple\Tests\PimpleTest::testOffsetGetHonorsNullValues ( )

Definition at line 118 of file PimpleTest.php.

119  {
120  $pimple = new Container();
121  $pimple['foo'] = null;
122  $this->assertNull($pimple['foo']);
123  }

◆ testOffsetGetValidatesKeyIsPresent()

Pimple\Tests\PimpleTest::testOffsetGetValidatesKeyIsPresent ( )

Identifier "foo" is not defined.

Definition at line 112 of file PimpleTest.php.

113  {
114  $pimple = new Container();
115  echo $pimple['foo'];
116  }

◆ testOverridingServiceAfterFreeze()

Pimple\Tests\PimpleTest::testOverridingServiceAfterFreeze ( )

Cannot override frozen service "foo".

Definition at line 381 of file PimpleTest.php.

382  {
383  $pimple = new Container();
384  $pimple['foo'] = function () {
385  return 'foo';
386  };
387  $foo = $pimple['foo'];
388 
389  $pimple['foo'] = function () {
390  return 'bar';
391  };
392  }

◆ testProtect()

Pimple\Tests\PimpleTest::testProtect (   $service)

serviceDefinitionProvider

Definition at line 158 of file PimpleTest.php.

159  {
160  $pimple = new Container();
161  $pimple['protected'] = $pimple->protect($service);
162 
163  $this->assertSame($service, $pimple['protected']);
164  }

◆ testProtectFailsForInvalidServiceDefinitions()

Pimple\Tests\PimpleTest::testProtectFailsForInvalidServiceDefinitions (   $service)

badServiceDefinitionProvider Callable is not a Closure or invokable object.

Definition at line 306 of file PimpleTest.php.

307  {
308  $pimple = new Container();
309  $pimple->protect($service);
310  }

◆ testRaw()

Pimple\Tests\PimpleTest::testRaw ( )

Definition at line 173 of file PimpleTest.php.

174  {
175  $pimple = new Container();
176  $pimple['service'] = $definition = $pimple->factory(function () { return 'foo'; });
177  $this->assertSame($definition, $pimple->raw('service'));
178  }

◆ testRawHonorsNullValues()

Pimple\Tests\PimpleTest::testRawHonorsNullValues ( )

Definition at line 180 of file PimpleTest.php.

181  {
182  $pimple = new Container();
183  $pimple['foo'] = null;
184  $this->assertNull($pimple->raw('foo'));
185  }

◆ testRawValidatesKeyIsPresent()

Pimple\Tests\PimpleTest::testRawValidatesKeyIsPresent ( )

Identifier "foo" is not defined.

Definition at line 197 of file PimpleTest.php.

198  {
199  $pimple = new Container();
200  $pimple->raw('foo');
201  }

◆ testRemovingServiceAfterFreeze()

Pimple\Tests\PimpleTest::testRemovingServiceAfterFreeze ( )

Definition at line 394 of file PimpleTest.php.

395  {
396  $pimple = new Container();
397  $pimple['foo'] = function () {
398  return 'foo';
399  };
400  $foo = $pimple['foo'];
401 
402  unset($pimple['foo']);
403  $pimple['foo'] = function () {
404  return 'bar';
405  };
406  $this->assertSame('bar', $pimple['foo']);
407  }

◆ testServicesShouldBeDifferent()

Pimple\Tests\PimpleTest::testServicesShouldBeDifferent ( )

Definition at line 54 of file PimpleTest.php.

55  {
56  $pimple = new Container();
57  $pimple['service'] = $pimple->factory(function () {
58  return new Fixtures\Service();
59  });
60 
61  $serviceOne = $pimple['service'];
62  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
63 
64  $serviceTwo = $pimple['service'];
65  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
66 
67  $this->assertNotSame($serviceOne, $serviceTwo);
68  }

◆ testShare()

Pimple\Tests\PimpleTest::testShare (   $service)

serviceDefinitionProvider

Definition at line 141 of file PimpleTest.php.

142  {
143  $pimple = new Container();
144  $pimple['shared_service'] = $service;
145 
146  $serviceOne = $pimple['shared_service'];
147  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
148 
149  $serviceTwo = $pimple['shared_service'];
150  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
151 
152  $this->assertSame($serviceOne, $serviceTwo);
153  }

◆ testShouldPassContainerAsParameter()

Pimple\Tests\PimpleTest::testShouldPassContainerAsParameter ( )

Definition at line 70 of file PimpleTest.php.

References $container.

71  {
72  $pimple = new Container();
73  $pimple['service'] = function () {
74  return new Fixtures\Service();
75  };
76  $pimple['container'] = function ($container) {
77  return $container;
78  };
79 
80  $this->assertNotSame($pimple, $pimple['service']);
81  $this->assertSame($pimple, $pimple['container']);
82  }
$container
Definition: wac.php:13

◆ testUnset()

Pimple\Tests\PimpleTest::testUnset ( )

Definition at line 125 of file PimpleTest.php.

126  {
127  $pimple = new Container();
128  $pimple['param'] = 'value';
129  $pimple['service'] = function () {
130  return new Fixtures\Service();
131  };
132 
133  unset($pimple['param'], $pimple['service']);
134  $this->assertFalse(isset($pimple['param']));
135  $this->assertFalse(isset($pimple['service']));
136  }

◆ testWithClosure()

Pimple\Tests\PimpleTest::testWithClosure ( )

Definition at line 44 of file PimpleTest.php.

45  {
46  $pimple = new Container();
47  $pimple['service'] = function () {
48  return new Fixtures\Service();
49  };
50 
51  $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']);
52  }

◆ testWithString()

Pimple\Tests\PimpleTest::testWithString ( )

Definition at line 36 of file PimpleTest.php.

37  {
38  $pimple = new Container();
39  $pimple['param'] = 'value';
40 
41  $this->assertEquals('value', $pimple['param']);
42  }

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