Best Atoum code snippet using manager.add
ServiceManagerTest.php
Source:ServiceManagerTest.php
...86 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidServiceNameException');87 $this->serviceManager->setFactory('foo', 'bar');88 }89 /**90 * @covers Zend\ServiceManager\ServiceManager::addAbstractFactory91 */92 public function testAddAbstractFactory()93 {94 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');95 $ret = $this->serviceManager->addAbstractFactory(new TestAsset\FooAbstractFactory());96 $this->assertSame($this->serviceManager, $ret);97 }98 /**99 * @covers Zend\ServiceManager\ServiceManager::addAbstractFactory100 */101 public function testAddAbstractFactoryThrowsExceptionOnInvalidFactory()102 {103 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidArgumentException');104 $this->serviceManager->addAbstractFactory(10);105 }106 public function testServiceManagerIsPassedToInitializer()107 {108 $initializer = new TestAsset\FooInitializer();109 $this->serviceManager->addInitializer($initializer);110 $this->serviceManager->setFactory('foo', function () {111 return new \stdClass();112 });113 $obj = $this->serviceManager->get('foo');114 $this->assertSame($this->serviceManager, $initializer->sm);115 }116 /**117 * @covers Zend\ServiceManager\ServiceManager::addInitializer118 */119 public function testAddInitializer()120 {121 $ret = $this->serviceManager->addInitializer(new TestAsset\FooInitializer());122 $this->assertSame($this->serviceManager, $ret);123 }124 /**125 * @covers Zend\ServiceManager\ServiceManager::addInitializer126 */127 public function testAddInitializerThrowsExceptionOnInvalidInitializer()128 {129 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidArgumentException');130 $this->serviceManager->addInitializer(5);131 }132 /**133 * @covers Zend\ServiceManager\ServiceManager::setService134 */135 public function testSetService()136 {137 $ret = $this->serviceManager->setService('foo', 'bar');138 $this->assertSame($this->serviceManager, $ret);139 }140 /**141 * @covers Zend\ServiceManager\ServiceManager::setShared142 */143 public function testSetShared()144 {145 $this->serviceManager->setInvokableClass('foo', 'bar');146 $ret = $this->serviceManager->setShared('foo', true);147 $this->assertSame($this->serviceManager, $ret);148 }149 /**150 * @covers Zend\ServiceManager\ServiceManager::setShared151 */152 public function testSetSharedAbstractFactory()153 {154 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');155 $ret = $this->serviceManager->setShared('foo', false);156 $this->assertSame($this->serviceManager, $ret);157 }158 /**159 * @covers Zend\ServiceManager\ServiceManager::setShared160 */161 public function testSetSharedThrowsExceptionOnUnregisteredService()162 {163 $this->setExpectedException('Zend\ServiceManager\Exception\ServiceNotFoundException');164 $this->serviceManager->setShared('foo', true);165 }166 /**167 * @covers Zend\ServiceManager\ServiceManager::get168 */169 public function testGet()170 {171 $this->serviceManager->setService('foo', 'bar');172 $this->assertEquals('bar', $this->serviceManager->get('foo'));173 }174 /**175 * @covers Zend\ServiceManager\ServiceManager::get176 */177 public function testGetDoesNotThrowExceptionOnEmptyArray()178 {179 $this->serviceManager->setService('foo', array());180 $this->serviceManager->get('foo');181 }182 /**183 * @covers Zend\ServiceManager\ServiceManager::get184 */185 public function testGetThrowsExceptionOnUnknownService()186 {187 $this->setExpectedException('Zend\ServiceManager\Exception\ServiceNotFoundException');188 $this->assertEquals('bar', $this->serviceManager->get('foo'));189 }190 /**191 * @covers Zend\ServiceManager\ServiceManager::get192 */193 public function testGetUsesIndivualSharedSettingWhenSetAndDeviatesFromShareByDefaultSetting()194 {195 $this->serviceManager->setAllowOverride(true);196 $this->serviceManager->setShareByDefault(false);197 $this->serviceManager->setInvokableClass('foo', 'ZendTest\ServiceManager\TestAsset\Foo');198 $this->serviceManager->setShared('foo', true);199 $this->assertSame($this->serviceManager->get('foo'), $this->serviceManager->get('foo'));200 $this->serviceManager->setShareByDefault(true);201 $this->serviceManager->setInvokableClass('foo', 'ZendTest\ServiceManager\TestAsset\Foo');202 $this->serviceManager->setShared('foo', false);203 $this->assertNotSame($this->serviceManager->get('foo'), $this->serviceManager->get('foo'));204 }205 /**206 * @covers Zend\ServiceManager\ServiceManager::get207 */208 public function testGetWithAlias()209 {210 $this->serviceManager->setService('foo', 'bar');211 $this->serviceManager->setAlias('baz', 'foo');212 $this->assertEquals('bar', $this->serviceManager->get('baz'));213 }214 /**215 * @covers Zend\ServiceManager\ServiceManager::get216 */217 public function testGetAbstractFactoryWithAlias()218 {219 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');220 $this->serviceManager->setAlias('foo', 'ZendTest\ServiceManager\TestAsset\FooAbstractFactory');221 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));222 }223 /**224 * @covers Zend\ServiceManager\ServiceManager::get225 */226 public function testGetWithScopedContainer()227 {228 $this->serviceManager->setService('foo', 'bar');229 $scopedServiceManager = $this->serviceManager->createScopedServiceManager();230 $this->assertEquals('bar', $scopedServiceManager->get('foo'));231 }232 public function testCanRetrieveFromParentPeeringManager()233 {234 $parent = new ServiceManager();235 $parent->setService('foo', 'bar');236 $child = new ServiceManager();237 $child->addPeeringServiceManager($parent, ServiceManager::SCOPE_PARENT);238 $this->assertEquals('bar', $child->get('foo'));239 }240 public function testCanRetrieveFromChildPeeringManager()241 {242 $parent = new ServiceManager();243 $child = new ServiceManager();244 $child->addPeeringServiceManager($parent, ServiceManager::SCOPE_CHILD);245 $child->setService('foo', 'bar');246 $this->assertEquals('bar', $parent->get('foo'));247 }248 public function testAllowsRetrievingFromPeeringContainerFirst()249 {250 $parent = new ServiceManager();251 $parent->setFactory('foo', function ($sm) {252 return 'bar';253 });254 $child = new ServiceManager();255 $child->setFactory('foo', function ($sm) {256 return 'baz';257 });258 $child->addPeeringServiceManager($parent, ServiceManager::SCOPE_PARENT);259 $child->setRetrieveFromPeeringManagerFirst(true);260 $this->assertEquals('bar', $child->get('foo'));261 }262 /**263 * @covers Zend\ServiceManager\ServiceManager::create264 */265 public function testCreateWithInvokableClass()266 {267 $this->serviceManager->setInvokableClass('foo', 'ZendTest\ServiceManager\TestAsset\Foo');268 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));269 }270 /**271 * @covers Zend\ServiceManager\ServiceManager::create272 */273 public function testCreateWithFactoryInstance()274 {275 $this->serviceManager->setFactory('foo', 'ZendTest\ServiceManager\TestAsset\FooFactory');276 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));277 }278 /**279 * @covers Zend\ServiceManager\ServiceManager::create280 */281 public function testCreateWithCallableFactory()282 {283 $this->serviceManager->setFactory('foo', function () { return new TestAsset\Foo; });284 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));285 }286 /**287 * @covers Zend\ServiceManager\ServiceManager::create288 */289 public function testCreateWithAbstractFactory()290 {291 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');292 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));293 }294 /**295 * @covers Zend\ServiceManager\ServiceManager::create296 */297 public function testCreateWithMultipleAbstractFactories()298 {299 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\BarAbstractFactory');300 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');301 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $this->serviceManager->get('bar'));302 }303 /**304 * @covers Zend\ServiceManager\ServiceManager::create305 */306 public function testCreateTheSameServiceWithMultipleAbstractFactories()307 {308 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooFakeAbstractFactory');309 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');310 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));311 }312 /**313 * @covers Zend\ServiceManager\ServiceManager::create314 */315 public function testCreateTheSameServiceWithMultipleAbstractFactoriesReversePriority()316 {317 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');318 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooFakeAbstractFactory');319 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\FooFake', $this->serviceManager->get('foo'));320 }321 public function testCreateWithInitializerObject()322 {323 $this->serviceManager->addInitializer(new TestAsset\FooInitializer(array('foo' => 'bar')));324 $this->serviceManager->setFactory('foo', function () {325 return new \stdClass();326 });327 $obj = $this->serviceManager->get('foo');328 $this->assertEquals('bar', $obj->foo);329 }330 public function testHasReturnsFalseOnNonStringsAndArrays()331 {332 $obj = new \stdClass();333 $this->assertFalse($this->serviceManager->has($obj));334 }335 public function testHasAcceptsArrays()336 {337 $this->serviceManager->setInvokableClass('foobar', 'foo');338 $this->assertTrue($this->serviceManager->has(array('foobar', 'foo_bar')));339 }340 /**341 * @covers Zend\ServiceManager\ServiceManager::has342 */343 public function testHas()344 {345 $this->assertFalse($this->serviceManager->has('foo'));346 $this->serviceManager->setInvokableClass('foo', 'bar');347 $this->assertTrue($this->serviceManager->has('foo'));348 }349 /**350 * @covers Zend\ServiceManager\ServiceManager::setAlias351 */352 public function testSetAlias()353 {354 $this->serviceManager->setInvokableClass('foo', 'bar');355 $ret = $this->serviceManager->setAlias('bar', 'foo');356 $this->assertSame($this->serviceManager, $ret);357 }358 /**359 * @covers Zend\ServiceManager\ServiceManager::setAlias360 */361 public function testSetAliasThrowsExceptionOnInvalidAliasName()362 {363 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidServiceNameException');364 $this->serviceManager->setAlias(5, 10);365 }366 /**367 * @covers Zend\ServiceManager\ServiceManager::setAlias368 */369 public function testSetAliasThrowsExceptionOnEmptyAliasName()370 {371 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidServiceNameException');372 $this->serviceManager->setAlias('', 'foo');373 }374 /**375 * @covers Zend\ServiceManager\ServiceManager::setAlias376 */377 public function testSetAliasThrowsExceptionOnDuplicateAlias()378 {379 $this->serviceManager->setService('foo', 'bar');380 $this->serviceManager->setAlias('baz', 'foo');381 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidServiceNameException');382 $this->serviceManager->setAlias('baz', 'foo');383 }384 /**385 * @covers Zend\ServiceManager\ServiceManager::setAlias386 */387 public function testSetAliasDoesNotThrowExceptionOnServiceNotFound()388 {389 $this->serviceManager->setAlias('foo', 'bar');390 }391 /**392 * @covers Zend\ServiceManager\ServiceManager::get393 */394 public function testGetServiceThrowsExceptionOnAliasWithNoSetService()395 {396 $this->setExpectedException('Zend\ServiceManager\Exception\ServiceNotFoundException');397 $this->serviceManager->setAlias('foo', 'bar');398 $this->serviceManager->get('foo');399 }400 /**401 * @cover Zend\ServiceManager\ServiceManager::get402 */403 public function testGetServiceThrowsExceptionOnMultipleAliasesWithNoSetService()404 {405 $this->setExpectedException('Zend\ServiceManager\Exception\ServiceNotFoundException');406 $this->serviceManager->setAlias('foo', 'bar');407 $this->serviceManager->setAlias('baz', 'foo');408 $this->serviceManager->get('foo');409 }410 /**411 * @covers Zend\ServiceManager\ServiceManager::hasAlias412 */413 public function testHasAlias()414 {415 $this->assertFalse($this->serviceManager->hasAlias('foo'));416 $this->serviceManager->setService('bar', 'baz');417 $this->serviceManager->setAlias('foo', 'bar');418 $this->assertTrue($this->serviceManager->hasAlias('foo'));419 }420 /**421 * @covers Zend\ServiceManager\ServiceManager::createScopedServiceManager422 */423 public function testCreateScopedServiceManager()424 {425 $this->serviceManager->setService('foo', 'bar');426 $scopedServiceManager = $this->serviceManager->createScopedServiceManager();427 $this->assertNotSame($this->serviceManager, $scopedServiceManager);428 $this->assertFalse($scopedServiceManager->has('foo', true, false));429 $this->assertContains($this->serviceManager, $this->readAttribute($scopedServiceManager, 'peeringServiceManagers'));430 // test child scoped431 $childScopedServiceManager = $this->serviceManager->createScopedServiceManager(ServiceManager::SCOPE_CHILD);432 $this->assertContains($childScopedServiceManager, $this->readAttribute($this->serviceManager, 'peeringServiceManagers'));433 }434 public function testConfigureWithInvokableClass()435 {436 $config = new Config(array(437 'invokables' => array(438 'foo' => 'ZendTest\ServiceManager\TestAsset\Foo',439 ),440 ));441 $serviceManager = new ServiceManager($config);442 $foo = $serviceManager->get('foo');443 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $foo);444 }445 public function testPeeringService()446 {447 $di = new Di();448 $di->instanceManager()->setParameters('ZendTest\ServiceManager\TestAsset\Bar', array('foo' => array('a')));449 $this->serviceManager->addAbstractFactory(new DiAbstractServiceFactory($di));450 $sm = $this->serviceManager->createScopedServiceManager(ServiceManager::SCOPE_PARENT);451 $sm->setFactory('di', new DiFactory());452 $bar = $sm->get('ZendTest\ServiceManager\TestAsset\Bar', true);453 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $bar);454 }455 public function testDiAbstractServiceFactory()456 {457 $di = $this->getMock('Zend\Di\Di');458 $factory = new DiAbstractServiceFactory($di);459 $factory->instanceManager()->setConfig('ZendTest\ServiceManager\TestAsset\Bar', array('parameters' => array('foo' => array('a'))));460 $this->serviceManager->addAbstractFactory($factory);461 $this->assertTrue($this->serviceManager->has('ZendTest\ServiceManager\TestAsset\Bar', true));462 $bar = $this->serviceManager->get('ZendTest\ServiceManager\TestAsset\Bar', true);463 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $bar);464 }465 public function testExceptionThrowingFactory()466 {467 $this->serviceManager->setFactory('foo', 'ZendTest\ServiceManager\TestAsset\ExceptionThrowingFactory');468 try {469 $this->serviceManager->get('foo');470 $this->fail("No exception thrown");471 } catch (Exception\ServiceNotCreatedException $e) {472 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\FooException', $e->getPrevious());473 }474 }475 /**476 * @expectedException Zend\ServiceManager\Exception\ServiceNotFoundException477 */478 public function testCannotUseUnknownServiceNameForAbstractFactory()479 {480 $config = new Config(array(481 'abstract_factories' => array(482 'ZendTest\ServiceManager\TestAsset\FooAbstractFactory',483 ),484 ));485 $serviceManager = new ServiceManager($config);486 $serviceManager->setFactory('foo', 'ZendTest\ServiceManager\TestAsset\FooFactory');487 $foo = $serviceManager->get('unknownObject');488 }489 /**490 * @expectedException Zend\ServiceManager\Exception\ServiceNotCreatedException491 */492 public function testDoNotFallbackToAbstractFactory()493 {494 $factory = function ($sm) {495 return new TestAsset\Bar();496 };497 $serviceManager = new ServiceManager();498 $serviceManager->setFactory('ZendTest\ServiceManager\TestAsset\Bar', $factory);499 $di = new Di();500 $di->instanceManager()->setParameters('ZendTest\ServiceManager\TestAsset\Bar', array('foo' => array('a')));501 $serviceManager->addAbstractFactory(new DiAbstractServiceFactory($di));502 $bar = $serviceManager->get('ZendTest\ServiceManager\TestAsset\Bar');503 }504 /**505 * @expectedException Zend\ServiceManager\Exception\InvalidServiceNameException506 */507 public function testAssignAliasWithExistingServiceName()508 {509 $this->serviceManager->setFactory('foo', 'ZendTest\ServiceManager\TestAsset\FooFactory');510 $this->serviceManager->setFactory('bar', function ($sm) {511 return new Bar(array('a'));512 });513 $this->serviceManager->setAllowOverride(false);514 // should throw an exception because 'foo' already exists in the service manager515 $this->serviceManager->setAlias('foo', 'bar');516 }517 /**518 * @covers Zend\ServiceManager\ServiceManager::createFromAbstractFactory519 * @covers Zend\ServiceManager\ServiceManager::has520 */521 public function testWillNotCreateCircularReferences()522 {523 $abstractFactory = new TestAsset\CircularDependencyAbstractFactory();524 $sm = new ServiceManager();525 $sm->addAbstractFactory($abstractFactory);526 $foo = $sm->get('foo');527 $this->assertSame($abstractFactory->expectedInstance, $foo);528 }529 /**530 * When failing, this test will trigger a fatal error: Allowed memory size of # bytes exhausted531 */532 public function testCallingANonExistingServiceFromAnAbstractServiceDoesNotMakeTheServerExhaustTheAllowedMemoryByCallingItselfForTheGivenService()533 {534 $abstractFactory = new TestAsset\TrollAbstractFactory;535 $this->serviceManager->addAbstractFactory($abstractFactory);536 $this->assertSame($abstractFactory->inexistingServiceCheckResult, null);537 // By doing this the Service Manager will rely on the Abstract Service Factory538 $service = $this->serviceManager->get('SomethingThatCanBeCreated');539 $this->assertSame(false, $abstractFactory->inexistingServiceCheckResult);540 $this->assertInstanceOf('stdClass', $service);541 }542 public function testMultipleAbstractFactoriesWithOneLookingForANonExistingServiceDuringCanCreate()543 {544 $abstractFactory = new TestAsset\TrollAbstractFactory;545 $anotherAbstractFactory = $this->getMock('Zend\ServiceManager\AbstractFactoryInterface');546 $anotherAbstractFactory547 ->expects($this->exactly(2))548 ->method('canCreateServiceWithName')549 ->with(550 $this->serviceManager,551 $this->logicalOr('somethingthatcanbecreated', 'nonexistingservice'),552 $this->logicalOr('SomethingThatCanBeCreated', 'NonExistingService')553 )554 ->will($this->returnValue(false));555 $this->serviceManager->addAbstractFactory($abstractFactory);556 $this->serviceManager->addAbstractFactory($anotherAbstractFactory);557 $this->assertTrue($this->serviceManager->has('SomethingThatCanBeCreated'));558 $this->assertFalse($abstractFactory->inexistingServiceCheckResult);559 }560 public function testWaitingAbstractFactory()561 {562 $abstractFactory = new TestAsset\WaitingAbstractFactory;563 $this->serviceManager->addAbstractFactory($abstractFactory);564 $abstractFactory->waitingService = null;565 $abstractFactory->canCreateCallCount = 0;566 $this->assertFalse($this->serviceManager->has('SomethingThatCanBeCreated'));567 $this->assertEquals(1, $abstractFactory->canCreateCallCount);568 $abstractFactory->waitingService = 'SomethingThatCanBeCreated';569 $abstractFactory->canCreateCallCount = 0;570 $this->assertTrue($this->serviceManager->has('SomethingThatCanBeCreated'));571 $this->assertEquals(1, $abstractFactory->canCreateCallCount);572 $abstractFactory->canCreateCallCount = 0;573 $this->assertInstanceOf('stdClass', $this->serviceManager->get('SomethingThatCanBeCreated'));574 $this->assertEquals(1, $abstractFactory->canCreateCallCount);575 }576 public function testWaitingAbstractFactoryNestedContextCounterWhenThrowException()577 {578 $abstractFactory = new TestAsset\WaitingAbstractFactory;579 $this->serviceManager->addAbstractFactory($abstractFactory);580 $contextCounter = new \ReflectionProperty($this->serviceManager, 'nestedContextCounter');581 $contextCounter->setAccessible(true);582 $contextCounter->getValue($this->serviceManager);583 $abstractFactory->waitName = 'SomethingThatCanBeCreated';584 $abstractFactory->createNullService = true;585 $this->assertEquals(-1, $contextCounter->getValue($this->serviceManager));586 try {587 $this->serviceManager->get('SomethingThatCanBeCreated');588 $this->fail('serviceManager shoud throw Zend\ServiceManager\Exception\ServiceNotFoundException');589 } catch(\Exception $e) {590 if (stripos(get_class($e), 'PHPUnit') !== false) {591 throw $e;592 }593 $this->assertEquals(-1, $contextCounter->getValue($this->serviceManager));594 }595 $abstractFactory->createNullService = false;596 $abstractFactory->throwExceptionWhenCreate = true;597 try {598 $this->serviceManager->get('SomethingThatCanBeCreated');599 $this->fail('serviceManager shoud throw Zend\ServiceManager\Exception\ServiceNotCreatedException');600 } catch(\Exception $e) {601 if (stripos(get_class($e), 'PHPUnit') !== false) {602 throw $e;603 }604 $this->assertEquals(-1, $contextCounter->getValue($this->serviceManager));605 }606 }607 public function testShouldAllowAddingInitializersAsClassNames()608 {609 $result = $this->serviceManager->addInitializer('ZendTest\ServiceManager\TestAsset\FooInitializer');610 $this->assertSame($this->serviceManager, $result);611 }612 public function testShouldRaiseExceptionIfInitializerClassIsNotAnInitializerInterfaceImplementation()613 {614 $this->setExpectedException('Zend\ServiceManager\Exception\InvalidArgumentException');615 $result = $this->serviceManager->addInitializer(get_class($this));616 }617 public function testGetGlobIteratorServiceWorksProperly()618 {619 $config = new Config(array(620 'invokables' => array(621 'foo' => 'ZendTest\ServiceManager\TestAsset\GlobIteratorService',622 ),623 ));624 $serviceManager = new ServiceManager($config);625 $foo = $serviceManager->get('foo');626 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\GlobIteratorService', $foo);627 }628 public function duplicateService()629 {630 $self = $this;631 return array(632 array(633 'setFactory',634 function ($services) use ($self) {635 return $self;636 },637 $self,638 'assertSame',639 ),640 array(641 'setInvokableClass',642 'stdClass',643 'stdClass',644 'assertInstanceOf',645 ),646 array(647 'setService',648 $self,649 $self,650 'assertSame',651 ),652 );653 }654 /**655 * @dataProvider duplicateService656 */657 public function testWithAllowOverrideOnRegisteringAServiceDuplicatingAnExistingAliasShouldInvalidateTheAlias($method, $service, $expected, $assertion = 'assertSame')658 {659 $this->serviceManager->setAllowOverride(true);660 $sm = $this->serviceManager;661 $this->serviceManager->setFactory('http.response', function () use ($sm) {662 return $sm;663 });664 $this->serviceManager->setAlias('response', 'http.response');665 $this->assertSame($sm, $this->serviceManager->get('response'));666 $this->serviceManager->{$method}('response', $service);667 $this->{$assertion}($expected, $this->serviceManager->get('response'));668 }669 /**670 * @covers Zend\ServiceManager\ServiceManager::canonicalizeName671 */672 public function testCanonicalizeName()673 {674 $this->serviceManager->setService('foo_bar', new \stdClass());675 $this->assertEquals(true, $this->serviceManager->has('foo_bar'));676 $this->assertEquals(true, $this->serviceManager->has('foobar'));677 $this->assertEquals(true, $this->serviceManager->has('foo-bar'));678 $this->assertEquals(true, $this->serviceManager->has('foo/bar'));679 $this->assertEquals(true, $this->serviceManager->has('foo bar'));680 }681 /**682 * @covers Zend\ServiceManager\ServiceManager::canCreateFromAbstractFactory683 */684 public function testWanCreateFromAbstractFactoryWillNotInstantiateAbstractFactoryOnce()685 {686 $count = FooCounterAbstractFactory::$instantiationCount;687 $this->serviceManager->addAbstractFactory(__NAMESPACE__ . '\TestAsset\FooCounterAbstractFactory');688 $this->serviceManager->canCreateFromAbstractFactory('foo', 'foo');689 $this->serviceManager->canCreateFromAbstractFactory('foo', 'foo');690 $this->assertSame($count + 1, FooCounterAbstractFactory::$instantiationCount);691 }692 /**693 * @covers Zend\ServiceManager\ServiceManager::canCreateFromAbstractFactory694 * @covers Zend\ServiceManager\ServiceManager::create695 */696 public function testAbstractFactoryNotUsedIfNotAbleToCreate()697 {698 $service = new \stdClass;699 $af1 = $this->getMock('Zend\ServiceManager\AbstractFactoryInterface');700 $af1->expects($this->any())->method('canCreateServiceWithName')->will($this->returnValue(true));701 $af1->expects($this->any())->method('createServiceWithName')->will($this->returnValue($service));702 $af2 = $this->getMock('Zend\ServiceManager\AbstractFactoryInterface');703 $af2->expects($this->any())->method('canCreateServiceWithName')->will($this->returnValue(false));704 $af2->expects($this->never())->method('createServiceWithName');705 $this->serviceManager->addAbstractFactory($af1);706 $this->serviceManager->addAbstractFactory($af2);707 $this->assertSame($service, $this->serviceManager->create('test'));708 }709 /**710 * @covers Zend\ServiceManager\ServiceManager::setAlias711 * @covers Zend\ServiceManager\ServiceManager::get712 * @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManager713 */714 public function testCanGetAliasedServicesFromPeeringServiceManagers()715 {716 $service = new \stdClass();717 $peeringSm = new ServiceManager();718 $peeringSm->setService('actual-service-name', $service);719 $this->serviceManager->addPeeringServiceManager($peeringSm);720 $this->serviceManager->setAlias('alias-name', 'actual-service-name');721 $this->assertSame($service, $this->serviceManager->get('alias-name'));722 }723 /**724 * @covers Zend\ServiceManager\ServiceManager::get725 */726 public function testDuplicateNewInstanceMultipleAbstractFactories()727 {728 $this->serviceManager->setAllowOverride(true);729 $this->serviceManager->setShareByDefault(false);730 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\BarAbstractFactory');731 $this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');732 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $this->serviceManager->get('bar'));733 $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $this->serviceManager->get('bar'));734 }735 /**736 * @covers Zend\ServiceManager\ServiceManager::setService737 * @covers Zend\ServiceManager\ServiceManager::get738 * @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManagerFirst739 * @covers Zend\ServiceManager\ServiceManager::setRetrieveFromPeeringManagerFirst740 * @covers Zend\ServiceManager\ServiceManager::addPeeringServiceManager741 */742 public function testRetrieveServiceFromPeeringServiceManagerIfretrieveFromPeeringManagerFirstSetToTrueAndServiceNamesAreSame()743 {744 $foo1 = "foo1";745 $boo1 = "boo1";746 $boo2 = "boo2";747 $this->serviceManager->setService($foo1, $boo1);748 $this->assertEquals($this->serviceManager->get($foo1), $boo1);749 $serviceManagerChild = new ServiceManager();750 $serviceManagerChild->setService($foo1, $boo2);751 $this->assertEquals($serviceManagerChild->get($foo1), $boo2);752 $this->assertFalse($this->serviceManager->retrieveFromPeeringManagerFirst());753 $this->serviceManager->setRetrieveFromPeeringManagerFirst(true);754 $this->assertTrue($this->serviceManager->retrieveFromPeeringManagerFirst());755 $this->serviceManager->addPeeringServiceManager($serviceManagerChild);756 $this->assertContains($serviceManagerChild, $this->readAttribute($this->serviceManager, 'peeringServiceManagers'));757 $this->assertEquals($serviceManagerChild->get($foo1), $boo2);758 $this->assertEquals($this->serviceManager->get($foo1), $boo2);759 }760 /**761 * @covers Zend\ServiceManager\ServiceManager::create762 * @covers Zend\ServiceManager\ServiceManager::createDelegatorFromFactory763 * @covers Zend\ServiceManager\ServiceManager::createDelegatorCallback764 * @covers Zend\ServiceManager\ServiceManager::addDelegator765 */766 public function testUsesDelegatorWhenAvailable()767 {768 $delegator = $this->getMock('Zend\\ServiceManager\\DelegatorFactoryInterface');769 $this->serviceManager->setService('foo-delegator', $delegator);770 $this->serviceManager->addDelegator('foo-service', 'foo-delegator');771 $this->serviceManager->setInvokableClass('foo-service', 'stdClass');772 $delegator773 ->expects($this->once())774 ->method('createDelegatorWithName')775 ->with(776 $this->serviceManager,777 'fooservice',778 'foo-service',779 $this->callback(function ($callback) {780 if (!is_callable($callback)) {781 return false;782 }783 $service = call_user_func($callback);784 return $service instanceof \stdClass;785 })786 )787 ->will($this->returnValue($delegator));788 $this->assertSame($delegator, $this->serviceManager->create('foo-service'));789 }790 /**791 * @covers Zend\ServiceManager\ServiceManager::create792 * @covers Zend\ServiceManager\ServiceManager::createDelegatorFromFactory793 * @covers Zend\ServiceManager\ServiceManager::createDelegatorCallback794 * @covers Zend\ServiceManager\ServiceManager::addDelegator795 */796 public function testUsesMultipleDelegates()797 {798 $fooDelegator = new MockSelfReturningDelegatorFactory();799 $barDelegator = new MockSelfReturningDelegatorFactory();800 $this->serviceManager->setService('foo-delegate', $fooDelegator);801 $this->serviceManager->setService('bar-delegate', $barDelegator);802 $this->serviceManager->addDelegator('foo-service', 'foo-delegate');803 $this->serviceManager->addDelegator('foo-service', 'bar-delegate');804 $this->serviceManager->setInvokableClass('foo-service', 'stdClass');805 $this->assertSame($barDelegator, $this->serviceManager->create('foo-service'));806 $this->assertCount(1, $barDelegator->instances);807 $this->assertCount(1, $fooDelegator->instances);808 $this->assertInstanceOf('stdClass', array_shift($fooDelegator->instances));809 $this->assertSame($fooDelegator, array_shift($barDelegator->instances));810 }811 /**812 * @covers Zend\ServiceManager\ServiceManager::resolveAlias813 */814 public function testSetCircularAliasReferenceThrowsException()815 {816 $this->setExpectedException('Zend\ServiceManager\Exception\CircularReferenceException');817 // Only affects service managers that allow overwriting definitions818 $this->serviceManager->setAllowOverride(true);819 $this->serviceManager->setInvokableClass('foo-service', 'stdClass');820 $this->serviceManager->setAlias('foo-alias', 'foo-service');821 $this->serviceManager->setAlias('bar-alias', 'foo-alias');822 $this->serviceManager->setAlias('baz-alias', 'bar-alias');823 // This will now cause a cyclic reference and should throw an exception824 $this->serviceManager->setAlias('foo-alias', 'bar-alias');825 }826 /**827 * @covers Zend\ServiceManager\ServiceManager::checkForCircularAliasReference828 */829 public function testResolveCircularAliasReferenceThrowsException()830 {831 $this->setExpectedException('Zend\ServiceManager\Exception\CircularReferenceException');832 // simulate an inconsistent state of $servicemanager->aliases as it could be833 // caused by derived classes834 $cyclicAliases = array(835 'fooalias' => 'bazalias',836 'baralias' => 'fooalias',837 'bazalias' => 'baralias'838 );839 $reflection = new \ReflectionObject($this->serviceManager);840 $propertyReflection = $reflection->getProperty('aliases');841 $propertyReflection->setAccessible(true);842 $propertyReflection->setValue($this->serviceManager, $cyclicAliases);843 // This should throw the exception844 $this->serviceManager->get('baz-alias');845 }846 /**847 * @covers Zend\ServiceManager\ServiceManager::createDelegatorFromFactory848 */849 public function testDelegatorFactoryWhenNotRegisteredAsService()850 {851 $delegator = $this->getMock('Zend\\ServiceManager\\DelegatorFactoryInterface');852 $this->serviceManager->addDelegator('foo-service', $delegator);853 $this->serviceManager->setInvokableClass('foo-service', 'stdClass');854 $delegator855 ->expects($this->once())856 ->method('createDelegatorWithName')857 ->with(858 $this->serviceManager,859 'fooservice',860 'foo-service',861 $this->callback(function ($callback) {862 if (!is_callable($callback)) {863 return false;864 }865 $service = call_user_func($callback);866 return $service instanceof \stdClass;867 })868 )869 ->will($this->returnValue($delegator));870 $this->assertSame($delegator, $this->serviceManager->create('foo-service'));871 }872 /**873 * @covers Zend\ServiceManager\ServiceManager::create874 * @covers Zend\ServiceManager\ServiceManager::createDelegatorFromFactory875 * @covers Zend\ServiceManager\ServiceManager::createDelegatorCallback876 * @covers Zend\ServiceManager\ServiceManager::addDelegator877 */878 public function testMultipleDelegatorFactoriesWhenNotRegisteredAsServices()879 {880 $fooDelegator = new MockSelfReturningDelegatorFactory();881 $barDelegator = new MockSelfReturningDelegatorFactory();882 $this->serviceManager->addDelegator('foo-service', $fooDelegator);883 $this->serviceManager->addDelegator('foo-service', $barDelegator);884 $this->serviceManager->setInvokableClass('foo-service', 'stdClass');885 $this->assertSame($barDelegator, $this->serviceManager->create('foo-service'));886 $this->assertCount(1, $barDelegator->instances);887 $this->assertCount(1, $fooDelegator->instances);888 $this->assertInstanceOf('stdClass', array_shift($fooDelegator->instances));889 $this->assertSame($fooDelegator, array_shift($barDelegator->instances));890 }891 public function testInvalidDelegatorFactoryThrowsException()892 {893 $delegatorFactory = new \stdClass;894 $this->serviceManager->addDelegator('foo-service', $delegatorFactory);895 try {896 $this->serviceManager->create('foo-service');897 $this->fail('Expected exception was not raised');898 }catch (Exception\ServiceNotCreatedException $expected) {899 $this->assertRegExp('/invalid factory/', $expected->getMessage());900 return;901 }902 }903 public function testInvalidDelegatorFactoryAmongMultipleOnesThrowsException()904 {905 $this->serviceManager->addDelegator('foo-service', new MockSelfReturningDelegatorFactory());906 $this->serviceManager->addDelegator('foo-service', new MockSelfReturningDelegatorFactory());907 $this->serviceManager->addDelegator('foo-service', 'stdClass');908 try {909 $this->serviceManager->create('foo-service');910 $this->fail('Expected exception was not raised');911 }catch (Exception\ServiceNotCreatedException $expected) {912 $this->assertRegExp('/invalid factory/', $expected->getMessage());913 return;914 }915 }916 public function testDelegatorFromCallback()917 {918 $realService = $this->getMock('stdClass', array(), array(), 'RealService');919 $delegator = $this->getMock('stdClass', array(), array(), 'Delegator');920 $delegatorFactoryCallback = function ($serviceManager, $cName, $rName, $callback) use ($delegator) {921 $delegator->real = call_user_func($callback);922 return $delegator;923 };924 $this->serviceManager->setFactory('foo-service', function () use ($realService) { return $realService; } );925 $this->serviceManager->addDelegator('foo-service', $delegatorFactoryCallback);926 $service = $this->serviceManager->create('foo-service');927 $this->assertSame($delegator, $service);928 $this->assertSame($realService, $service->real);929 }930 /**931 * @dataProvider getServiceOfVariousTypes932 * @param $service933 */934 public function testAbstractFactoriesCanReturnAnyTypeButNull($service)935 {936 $abstractFactory = $this->getMock('Zend\ServiceManager\AbstractFactoryInterface');937 $abstractFactory938 ->expects($this->any())939 ->method('canCreateServiceWithName')940 ->with($this->serviceManager, 'something', 'something')941 ->will($this->returnValue(true));942 $abstractFactory943 ->expects($this->any())944 ->method('createServiceWithName')945 ->with($this->serviceManager, 'something', 'something')946 ->will($this->returnValue($service));947 $this->serviceManager->addAbstractFactory($abstractFactory);948 if ($service === null) {949 try {950 $this->serviceManager->get('something');951 $this->fail('ServiceManager::get() successfully returned null');952 } catch(\Exception $e) {953 $this->assertInstanceOf('Zend\ServiceManager\Exception\ServiceNotCreatedException', $e);954 }955 } else {956 $this->assertSame($service, $this->serviceManager->get('something'));957 }958 }959 /**960 * @dataProvider getServiceOfVariousTypes961 * @param $service...
ModuleManagerFactory.php
Source:ModuleManagerFactory.php
...37 $configuration = $serviceLocator->get('ApplicationConfig');38 $listenerOptions = new ListenerOptions($configuration['module_listener_options']);39 $defaultListeners = new DefaultListenerAggregate($listenerOptions);40 $serviceListener = $serviceLocator->get('ServiceListener');41 $serviceListener->addServiceManager(42 $serviceLocator,43 'service_manager',44 'Zend\ModuleManager\Feature\ServiceProviderInterface',45 'getServiceConfig'46 );47 $serviceListener->addServiceManager(48 'ControllerLoader',49 'controllers',50 'Zend\ModuleManager\Feature\ControllerProviderInterface',51 'getControllerConfig'52 );53 $serviceListener->addServiceManager(54 'ControllerPluginManager',55 'controller_plugins',56 'Zend\ModuleManager\Feature\ControllerPluginProviderInterface',57 'getControllerPluginConfig'58 );59 $serviceListener->addServiceManager(60 'ViewHelperManager',61 'view_helpers',62 'Zend\ModuleManager\Feature\ViewHelperProviderInterface',63 'getViewHelperConfig'64 );65 $serviceListener->addServiceManager(66 'ValidatorManager',67 'validators',68 'Zend\ModuleManager\Feature\ValidatorProviderInterface',69 'getValidatorConfig'70 );71 $serviceListener->addServiceManager(72 'FilterManager',73 'filters',74 'Zend\ModuleManager\Feature\FilterProviderInterface',75 'getFilterConfig'76 );77 $serviceListener->addServiceManager(78 'FormElementManager',79 'form_elements',80 'Zend\ModuleManager\Feature\FormElementProviderInterface',81 'getFormElementConfig'82 );83 $serviceListener->addServiceManager(84 'RoutePluginManager',85 'route_manager',86 'Zend\ModuleManager\Feature\RouteProviderInterface',87 'getRouteConfig'88 );89 $serviceListener->addServiceManager(90 'SerializerAdapterManager',91 'serializers',92 'Zend\ModuleManager\Feature\SerializerProviderInterface',93 'getSerializerConfig'94 );95 $serviceListener->addServiceManager(96 'HydratorManager',97 'hydrators',98 'Zend\ModuleManager\Feature\HydratorProviderInterface',99 'getHydratorConfig'100 );101 $serviceListener->addServiceManager(102 'InputFilterManager',103 'input_filters',104 'Zend\ModuleManager\Feature\InputFilterProviderInterface',105 'getInputFilterConfig'106 );107 $serviceListener->addServiceManager(108 'LogProcessorManager',109 'log_processors',110 'Zend\ModuleManager\Feature\LogProcessorProviderInterface',111 'getLogProcessorConfig'112 );113 $serviceListener->addServiceManager(114 'LogWriterManager',115 'log_writers',116 'Zend\ModuleManager\Feature\LogWriterProviderInterface',117 'getLogWriterConfig'118 );119 $events = $serviceLocator->get('EventManager');120 $events->attach($defaultListeners);121 $events->attach($serviceListener);122 $moduleEvent = new ModuleEvent;123 $moduleEvent->setParam('ServiceManager', $serviceLocator);124 $moduleManager = new ModuleManager($configuration['modules'], $events);125 $moduleManager->setEvent($moduleEvent);126 return $moduleManager;127 }...
add
Using AI Code Generation
1require_once 'Manager.php';2$manager = new Manager();3$manager->add();4require_once 'Manager.php';5$manager = new Manager();6$manager->delete();7require_once 'Manager.php';8$manager = new Manager();9$manager->update();10require_once 'Manager.php';11$manager = new Manager();12$manager->view();
add
Using AI Code Generation
1$manager = new Manager();2$manager->add($employee1);3$manager->add($employee2);4$manager->add($employee3);5$manager->add($employee4);6$manager->add($employee5);7$manager->add($employee6);8$manager->add($employee7);9$manager->add($employee8);10$manager->add($employee9);11$manager->add($employee10);12$manager->add($employee11);13$manager->add($employee12);14$manager->add($employee13);15$manager->add($employee14);16$manager->add($employee15);17$manager->add($employee16);18$manager->add($employee17);19$manager->add($employee18);20$manager->add($employee19);21$manager->add($employee20);22$manager->add($employee21);23$manager->add($employee22);24$manager->add($employee23);25$manager->add($employee24);26$manager->add($employee25);27$manager->add($employee26);28$manager->add($employee27);29$manager->add($employee28);30$manager->add($employee29);31$manager->add($employee30);32$manager->add($employee31);33$manager->add($employee32);34$manager->add($employee33);35$manager->add($employee34);36$manager->add($employee35);37$manager->add($employee36);38$manager->add($employee37);39$manager->add($employee38);40$manager->add($employee39);41$manager->add($employee40);42$manager->add($employee41);43$manager->add($employee42);44$manager->add($employee43);45$manager->add($employee44);46$manager->add($employee45);47$manager->add($employee46);48$manager->add($employee47);49$manager->add($employee48);50$manager->add($employee49);51$manager->add($employee50);52$manager->add($employee51);53$manager->add($employee52);54$manager->add($employee53);55$manager->add($employee54);56$manager->add($employee55);57$manager->add($employee56);58$manager->add($employee57);59$manager->add($employee58);60$manager->add($employee59);61$manager->add($employee60);62$manager->add($employee61);
add
Using AI Code Generation
1require_once 'manager.php';2$manager = new Manager();3$manager->add(10,20);4require_once 'manager.php';5$manager = new Manager();6$manager->add(100,200);7require_once 'manager.php';8$manager = new Manager();9$manager->add(1000,2000);10require_once 'manager.php';11$manager = new Manager();12$manager->add(10,20);13require_once 'manager.php';14$manager = new Manager();15$manager->add(10,20);16require_once 'manager.php';17$manager = new Manager();18$manager->add(10,20);19require_once 'manager.php';20$manager = new Manager();21$manager->add(10,20);22require_once 'manager.php';23$manager = new Manager();24$manager->add(10,20);25require_once 'manager.php';26$manager = new Manager();27$manager->add(10,20);28require_once 'manager.php';29$manager = new Manager();30$manager->add(10,20);31require_once 'manager.php';32$manager = new Manager();33$manager->add(10,20);34require_once 'manager.php';35$manager = new Manager();36$manager->add(10,20);
add
Using AI Code Generation
1require_once 'Manager.php';2require_once 'Employee.php';3$manager = new Manager();4$employee = new Employee();5$manager->add($employee);6require_once 'Manager.php';7require_once 'Employee.php';8$manager = new Manager();9$employee = new Employee();10$manager->add($employee);11require_once 'Manager.php';12require_once 'Employee.php';13$manager = new Manager();14$employee = new Employee();15$manager->add($employee);16require_once 'Manager.php';17require_once 'Employee.php';18$manager = new Manager();19$employee = new Employee();20$manager->add($employee);21require_once 'Manager.php';22require_once 'Employee.php';23$manager = new Manager();24$employee = new Employee();25$manager->add($employee);26require_once 'Manager.php';27require_once 'Employee.php';28$manager = new Manager();29$employee = new Employee();30$manager->add($employee);31require_once 'Manager.php';32require_once 'Employee.php';33$manager = new Manager();34$employee = new Employee();35$manager->add($employee);36require_once 'Manager.php';37require_once 'Employee.php';38$manager = new Manager();39$employee = new Employee();40$manager->add($employee);41require_once 'Manager.php';42require_once 'Employee.php';43$manager = new Manager();44$employee = new Employee();45$manager->add($employee);46require_once 'Manager.php';47require_once 'Employee.php';48$manager = new Manager();49$employee = new Employee();50$manager->add($employee);
add
Using AI Code Generation
1require_once 'manager.php';2$manager = new Manager();3$manager->add(10, 20);4require_once 'manager.php';5$manager = new Manager();6$manager->multiply(10, 20);7require_once 'manager.php';8$manager = new Manager();9$manager->divide(10, 20);10require_once 'manager.php';11$manager = new Manager();12$manager->subtract(10, 20);13require_once 'manager.php';14$manager = new Manager();15$manager->add(10, 20);16require_once 'manager.php';17$manager = new Manager();18$manager->multiply(10, 20);19require_once 'manager.php';20$manager = new Manager();21$manager->divide(10, 20);22require_once 'manager.php';23$manager = new Manager();24$manager->subtract(10, 20);25require_once 'manager.php';26$manager = new Manager();27$manager->add(10, 20);28require_once 'manager.php';29$manager = new Manager();30$manager->multiply(10, 20);31require_once 'manager.php';32$manager = new Manager();33$manager->divide(10, 20);34require_once 'manager.php';35$manager = new Manager();36$manager->subtract(10, 20);37require_once 'manager.php';38$manager = new Manager();39$manager->add(10, 20);
add
Using AI Code Generation
1require_once 'manager.php';2require_once 'employee.php';3$manager = new Manager('John', 'Doe', 60000);4$manager->addEmployee(new Employee('Jane', 'Doe', 30000));5$manager->addEmployee(new Employee('Mary', 'Doe', 30000));6echo $manager->getSalary();7require_once 'manager.php';8require_once 'employee.php';9$manager = new Manager('John', 'Doe', 60000);10$manager->addEmployee(new Employee('Jane', 'Doe', 30000));11$manager->addEmployee(new Employee('Mary', 'Doe', 30000));12echo $manager->getSalary();13require_once 'manager.php';14require_once 'employee.php';15$manager = new Manager('John', 'Doe', 60000);16$manager->addEmployee(new Employee('Jane', 'Doe', 30000));17$manager->addEmployee(new Employee('Mary', 'Doe', 30000));18echo $manager->getSalary();19require_once 'manager.php';20require_once 'employee.php';21$manager = new Manager('John', 'Doe', 60000);22$manager->addEmployee(new Employee('Jane', 'Doe', 30000));23$manager->addEmployee(new Employee('Mary', 'Doe', 30000));24echo $manager->getSalary();25require_once 'manager.php';26require_once 'employee.php';27$manager = new Manager('John', 'Doe', 60000);28$manager->addEmployee(new Employee('Jane', 'Doe', 30000));29$manager->addEmployee(new Employee('Mary', 'Doe', 30000));30echo $manager->getSalary();31require_once 'manager.php';32require_once 'employee.php';33$manager = new Manager('John', 'Doe', 60000);34$manager->addEmployee(new Employee('Jane', 'Doe', 30000));35$manager->addEmployee(new Employee
add
Using AI Code Generation
1require_once('manager.php');2$manager = new Manager();3require_once('manager.php');4$manager = new Manager();5require_once('manager.php');6$manager = new Manager();7require_once('manager.php');8$manager = new Manager();9require_once('manager.php');10$manager = new Manager();11require_once('manager.php');12$manager = new Manager();13require_once('manager.php');14$manager = new Manager();15require_once('manager.php');16$manager = new Manager();
add
Using AI Code Generation
1require_once('manager.php');2require_once('employee.php');3$manager = new Manager();4$manager->add(1,'Rajesh',10000);5$manager->add(2,'Rajesh',10000);6$manager->add(3,'Rajesh',10000);7$manager->add(4,'Rajesh',10000);8$manager->add(5,'Rajesh',10000);9$manager->add(6,'Rajesh',10000);10$manager->add(7,'Rajesh',10000);11$manager->add(8,'Rajesh',10000);12$manager->add(9,'Rajesh',10000);13$manager->add(10,'Rajesh',10000);14$manager->add(11,'Rajesh',10000);15$manager->add(12,'Rajesh',10000);16$manager->add(13,'Rajesh',10000);17$manager->add(14,'Rajesh',10000);18$manager->add(15,'Rajesh',10000);19$manager->add(16,'Rajesh',10000);20$manager->add(17,'Rajesh',10000);21$manager->add(18,'Rajesh',10000);22$manager->add(19,'Rajesh',10000);23$manager->add(20,'Rajesh',10000);24$manager->add(21,'Rajesh',10000);25$manager->add(22,'Rajesh',10000);26$manager->add(23,'Rajesh',10000);27$manager->add(24,'Rajesh',10000);28$manager->add(25,'Rajesh',10000);29$manager->add(26,'Rajesh',10000);30$manager->add(27,'Rajesh',10000);31$manager->add(28,'Rajesh',10000);32$manager->add(29,'Rajesh',10000);33$manager->add(30,'Rajesh',10000);34$manager->add(31,'Rajesh',10000);35$manager->add(32,'Rajesh',10000);36$manager->add(33,'Rajesh',10000);37$manager->add(34,'Rajesh',10000);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with add on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!