/** * Tests the standard set/get methods of the DI. * @dataProvider setAndGetServiceProvider */ public function testSetAndGetService($key, $element, $expected) { $di = new DI(); $di->set($key, $element); // check that we get back what we expect $this->assertEquals($expected, $di->get($key, false)); // check we get the same value if we use the cache $this->assertEquals($expected, $di->get($key, true)); // and again if we force a "no cache" hit $this->assertEquals($expected, $di->get($key, false)); $this->assertTrue($di->hasElement($key)); $this->assertEquals(array($key), $di->allRegisteredElements()); }