How to use injector class

Best Atoum code snippet using injector

InjectorTest.php

Source:InjectorTest.php Github

copy

Full Screen

...4class InjectorTest extends \PHPUnit_Framework_TestCase5{6 public function testMakeInstanceInjectsSimpleConcreteDependency()7 {8 $injector = new Injector;9 $this->assertEquals(new TestNeedsDep(new TestDependency),10 $injector->make('Auryn\Test\TestNeedsDep')11 );12 }13 public function testMakeInstanceReturnsNewInstanceIfClassHasNoConstructor()14 {15 $injector = new Injector;16 $this->assertEquals(new TestNoConstructor, $injector->make('Auryn\Test\TestNoConstructor'));17 }18 public function testMakeInstanceReturnsAliasInstanceOnNonConcreteTypehint()19 {20 $injector = new Injector;21 $injector->alias('Auryn\Test\DepInterface', 'Auryn\Test\DepImplementation');22 $this->assertEquals(new DepImplementation, $injector->make('Auryn\Test\DepInterface'));23 }24 /**25 * @expectedException \Auryn\InjectionException26 * @expectedExceptionCode \Auryn\Injector::E_NEEDS_DEFINITION27 */28 public function testMakeInstanceThrowsExceptionOnInterfaceWithoutAlias()29 {30 $injector = new Injector;31 $injector->make('Auryn\Test\DepInterface');32 }33 /**34 * @expectedException \Auryn\InjectionException35 * @expectedExceptionCode \Auryn\Injector::E_NEEDS_DEFINITION36 */37 public function testMakeInstanceThrowsExceptionOnNonConcreteCtorParamWithoutImplementation()38 {39 $injector = new Injector;40 $injector->make('Auryn\Test\RequiresInterface');41 }42 public function testMakeInstanceBuildsNonConcreteCtorParamWithAlias()43 {44 $injector = new Injector;45 $injector->alias('Auryn\Test\DepInterface', 'Auryn\Test\DepImplementation');46 $obj = $injector->make('Auryn\Test\RequiresInterface');47 $this->assertInstanceOf('Auryn\Test\RequiresInterface', $obj);48 }49 public function testMakeInstancePassesNullCtorParameterIfNoTypehintOrDefaultCanBeDetermined()50 {51 $injector = new Injector;52 $nullCtorParamObj = $injector->make('Auryn\Test\ProvTestNoDefinitionNullDefaultClass');53 $this->assertEquals(new ProvTestNoDefinitionNullDefaultClass, $nullCtorParamObj);54 $this->assertEquals(null, $nullCtorParamObj->arg);55 }56 public function testMakeInstanceReturnsSharedInstanceIfAvailable()57 {58 $injector = new Injector;59 $injector->define('Auryn\Test\RequiresInterface', array('dep' => 'Auryn\Test\DepImplementation'));60 $injector->share('Auryn\Test\RequiresInterface');61 $injected = $injector->make('Auryn\Test\RequiresInterface');62 $this->assertEquals('something', $injected->testDep->testProp);63 $injected->testDep->testProp = 'something else';64 $injected2 = $injector->make('Auryn\Test\RequiresInterface');65 $this->assertEquals('something else', $injected2->testDep->testProp);66 }67 /**68 * @expectedException Auryn\InjectorException69 */70 public function testMakeInstanceThrowsExceptionOnClassLoadFailure()71 {72 $injector = new Injector;73 $injector->make('ClassThatDoesntExist');74 }75 public function testMakeInstanceUsesCustomDefinitionIfSpecified()76 {77 $injector = new Injector;78 $injector->define('Auryn\Test\TestNeedsDep', array('testDep'=>'Auryn\Test\TestDependency'));79 $injected = $injector->make('Auryn\Test\TestNeedsDep', array('testDep'=>'Auryn\Test\TestDependency2'));80 $this->assertEquals('testVal2', $injected->testDep->testProp);81 }82 public function testMakeInstanceCustomDefinitionOverridesExistingDefinitions()83 {84 $injector = new Injector;85 $injector->define('Auryn\Test\InjectorTestChildClass', array(':arg1'=>'First argument', ':arg2'=>'Second argument'));86 $injected = $injector->make('Auryn\Test\InjectorTestChildClass', array(':arg1'=>'Override'));87 $this->assertEquals('Override', $injected->arg1);88 $this->assertEquals('Second argument', $injected->arg2);89 }90 public function testMakeInstanceStoresShareIfMarkedWithNullInstance()91 {92 $injector = new Injector;93 $injector->share('Auryn\Test\TestDependency');94 $injector->make('Auryn\Test\TestDependency');95 }96 public function testMakeInstanceUsesReflectionForUnknownParamsInMultiBuildWithDeps()97 {98 $injector = new Injector;99 $obj = $injector->make('Auryn\Test\TestMultiDepsWithCtor', array('val1'=>'Auryn\Test\TestDependency'));100 $this->assertInstanceOf('Auryn\Test\TestMultiDepsWithCtor', $obj);101 $obj = $injector->make('Auryn\Test\NoTypehintNoDefaultConstructorClass',102 array('val1'=>'Auryn\Test\TestDependency')103 );104 $this->assertInstanceOf('Auryn\Test\NoTypehintNoDefaultConstructorClass', $obj);105 $this->assertEquals(null, $obj->testParam);106 }107 /**108 * @expectedException \Auryn\InjectionException109 * @expectedExceptionCode \Auryn\Injector::E_UNDEFINED_PARAM110 */111 public function testMakeInstanceThrowsExceptionOnUntypehintedParameterWithoutDefinitionOrDefault()112 {113 $injector = new Injector;114 $obj = $injector->make('Auryn\Test\InjectorTestCtorParamWithNoTypehintOrDefault');115 $this->assertNull($obj->val);116 }117 /**118 * @expectedException \Auryn\InjectionException119 * @expectedExceptionCode \Auryn\Injector::E_UNDEFINED_PARAM120 */121 public function testMakeInstanceThrowsExceptionOnUntypehintedParameterWithoutDefinitionOrDefaultThroughAliasedTypehint()122 {123 $injector = new Injector;124 $injector->alias('Auryn\Test\TestNoExplicitDefine', 'Auryn\Test\InjectorTestCtorParamWithNoTypehintOrDefault');125 $injector->make('Auryn\Test\InjectorTestCtorParamWithNoTypehintOrDefaultDependent');126 }127 /**128 * @TODO129 * @expectedException Auryn\InjectorException130 */131 public function testMakeInstanceThrowsExceptionOnUninstantiableTypehintWithoutDefinition()132 {133 $injector = new Injector;134 $obj = $injector->make('Auryn\Test\RequiresInterface');135 }136 public function testTypelessDefineForDependency()137 {138 $thumbnailSize = 128;139 $injector = new Injector;140 $injector->defineParam('thumbnailSize', $thumbnailSize);141 $testClass = $injector->make('Auryn\Test\RequiresDependencyWithTypelessParameters');142 $this->assertEquals($thumbnailSize, $testClass->getThumbnailSize(), 'Typeless define was not injected correctly.');143 }144 public function testTypelessDefineForAliasedDependency()145 {146 $injector = new Injector;147 $injector->defineParam('val', 42);148 $injector->alias('Auryn\Test\TestNoExplicitDefine', 'Auryn\Test\ProviderTestCtorParamWithNoTypehintOrDefault');149 $obj = $injector->make('Auryn\Test\ProviderTestCtorParamWithNoTypehintOrDefaultDependent');150 }151 public function testMakeInstanceInjectsRawParametersDirectly()152 {153 $injector = new Injector;154 $injector->define('Auryn\Test\InjectorTestRawCtorParams', array(155 ':string' => 'string',156 ':obj' => new \StdClass,157 ':int' => 42,158 ':array' => array(),159 ':float' => 9.3,160 ':bool' => true,161 ':null' => null,162 ));163 $obj = $injector->make('Auryn\Test\InjectorTestRawCtorParams');164 $this->assertInternalType('string', $obj->string);165 $this->assertInstanceOf('StdClass', $obj->obj);166 $this->assertInternalType('int', $obj->int);167 $this->assertInternalType('array', $obj->array);168 $this->assertInternalType('float', $obj->float);169 $this->assertInternalType('bool', $obj->bool);170 $this->assertNull($obj->null);171 }172 /**173 * @TODO174 * @expectedException \Exception175 */176 public function testMakeInstanceThrowsExceptionWhenDelegateDoes()177 {178 $injector= new Injector;179 $callable = $this->getMock(180 'CallableMock',181 array('__invoke')182 );183 $injector->delegate('TestDependency', $callable);184 $callable->expects($this->once())185 ->method('__invoke')186 ->will($this->throwException(new \Exception()));187 $injector->make('TestDependency');188 }189 public function testMakeInstanceHandlesNamespacedClasses()190 {191 $injector = new Injector;192 $injector->make('Auryn\Test\SomeClassName');193 }194 public function testMakeInstanceDelegate()195 {196 $injector= new Injector;197 $callable = $this->getMock(198 'CallableMock',199 array('__invoke')200 );201 $callable->expects($this->once())202 ->method('__invoke')203 ->will($this->returnValue(new TestDependency()));204 $injector->delegate('Auryn\Test\TestDependency', $callable);205 $obj = $injector->make('Auryn\Test\TestDependency');206 $this->assertInstanceOf('Auryn\Test\TestDependency', $obj);207 }208 public function testMakeInstanceWithStringDelegate()209 {210 $injector= new Injector;211 $injector->delegate('StdClass', 'Auryn\Test\StringStdClassDelegateMock');212 $obj = $injector->make('StdClass');213 $this->assertEquals(42, $obj->test);214 }215 /**216 * @expectedException Auryn\ConfigException217 */218 public function testMakeInstanceThrowsExceptionIfStringDelegateClassHasNoInvokeMethod()219 {220 $injector= new Injector;221 $injector->delegate('StdClass', 'StringDelegateWithNoInvokeMethod');222 }223 /**224 * @expectedException Auryn\ConfigException225 */226 public function testMakeInstanceThrowsExceptionIfStringDelegateClassInstantiationFails()227 {228 $injector= new Injector;229 $injector->delegate('StdClass', 'SomeClassThatDefinitelyDoesNotExistForReal');230 }231 /**232 * @expectedException \Auryn\InjectionException233 */234 public function testMakeInstanceThrowsExceptionOnUntypehintedParameterWithNoDefinition()235 {236 $injector = new Injector;237 $obj = $injector->make('Auryn\Test\RequiresInterface');238 }239 public function testDefineAssignsPassedDefinition()240 {241 $injector = new Injector;242 $definition = array('dep' => 'Auryn\Test\DepImplementation');243 $injector->define('Auryn\Test\RequiresInterface', $definition);244 $this->assertInstanceOf('Auryn\Test\RequiresInterface', $injector->make('Auryn\Test\RequiresInterface'));245 }246 public function testShareStoresSharedInstanceAndReturnsCurrentInstance()247 {248 $injector = new Injector;249 $testShare = new \StdClass;250 $testShare->test = 42;251 $this->assertInstanceOf('Auryn\Injector', $injector->share($testShare));252 $testShare->test = 'test';253 $this->assertEquals('test', $injector->make('stdclass')->test);254 }255 public function testShareMarksClassSharedOnNullObjectParameter()256 {257 $injector = new Injector;258 $this->assertInstanceOf('Auryn\Injector', $injector->share('SomeClass'));259 }260 /**261 * @expectedException \Auryn\ConfigException262 */263 public function testShareThrowsExceptionOnInvalidArgument()264 {265 $injector = new Injector;266 $injector->share(42);267 }268 public function testAliasAssignsValueAndReturnsCurrentInstance()269 {270 $injector = new Injector;271 $this->assertInstanceOf('Auryn\Injector', $injector->alias('DepInterface', 'Auryn\Test\DepImplementation'));272 }273 public function provideInvalidDelegates()274 {275 return array(276 array(new \StdClass),277 array(42),278 array(true)279 );280 }281 /**282 * @dataProvider provideInvalidDelegates283 * @expectedException Auryn\ConfigException284 */285 public function testDelegateThrowsExceptionIfDelegateIsNotCallableOrString($badDelegate)286 {287 $injector = new Injector;288 $injector->delegate('Auryn\Test\TestDependency', $badDelegate);289 }290 public function testDelegateInstantiatesCallableClassString()291 {292 $injector = new Injector;293 $injector->delegate('Auryn\Test\MadeByDelegate', 'Auryn\Test\CallableDelegateClassTest');294 $this->assertInstanceof('Auryn\Test\MadeByDelegate', $injector->make('Auryn\Test\MadeByDelegate'));295 }296 public function testDelegateInstantiatesCallableClassArray()297 {298 $injector = new Injector;299 $injector->delegate('Auryn\Test\MadeByDelegate', array('Auryn\Test\CallableDelegateClassTest', '__invoke'));300 $this->assertInstanceof('Auryn\Test\MadeByDelegate', $injector->make('Auryn\Test\MadeByDelegate'));301 }302 public function testUnknownDelegationFunction()303 {304 $injector = new Injector;305 try {306 $injector->delegate('Auryn\Test\DelegatableInterface', 'FunctionWhichDoesNotExist');307 $this->fail("Delegation was supposed to fail.");308 } catch (\Auryn\InjectorException $ie) {309 $this->assertContains('FunctionWhichDoesNotExist', $ie->getMessage());310 $this->assertEquals(\Auryn\Injector::E_DELEGATE_ARGUMENT, $ie->getCode());311 }312 }313 public function testUnknownDelegationMethod()314 {315 $injector = new Injector;316 try {317 $injector->delegate('Auryn\Test\DelegatableInterface', array('stdClass', 'methodWhichDoesNotExist'));318 $this->fail("Delegation was supposed to fail.");319 } catch (\Auryn\InjectorException $ie) {320 $this->assertContains('stdClass', $ie->getMessage());321 $this->assertContains('methodWhichDoesNotExist', $ie->getMessage());322 $this->assertEquals(\Auryn\Injector::E_DELEGATE_ARGUMENT, $ie->getCode());323 }324 }325 /**326 * @dataProvider provideExecutionExpectations327 */328 public function testProvisionedInvokables($toInvoke, $definition, $expectedResult)329 {330 $injector = new Injector;331 $this->assertEquals($expectedResult, $injector->execute($toInvoke, $definition));332 }333 public function provideExecutionExpectations()334 {335 $return = array();336 // 0 -------------------------------------------------------------------------------------->337 $toInvoke = array('Auryn\Test\ExecuteClassNoDeps', 'execute');338 $args = array();339 $expectedResult = 42;340 $return[] = array($toInvoke, $args, $expectedResult);341 // 1 -------------------------------------------------------------------------------------->342 $toInvoke = array(new ExecuteClassNoDeps, 'execute');343 $args = array();344 $expectedResult = 42;345 $return[] = array($toInvoke, $args, $expectedResult);346 // 2 -------------------------------------------------------------------------------------->347 $toInvoke = array('Auryn\Test\ExecuteClassDeps', 'execute');348 $args = array();349 $expectedResult = 42;350 $return[] = array($toInvoke, $args, $expectedResult);351 // 3 -------------------------------------------------------------------------------------->352 $toInvoke = array(new ExecuteClassDeps(new TestDependency), 'execute');353 $args = array();354 $expectedResult = 42;355 $return[] = array($toInvoke, $args, $expectedResult);356 // 4 -------------------------------------------------------------------------------------->357 $toInvoke = array('Auryn\Test\ExecuteClassDepsWithMethodDeps', 'execute');358 $args = array(':arg' => 9382);359 $expectedResult = 9382;360 $return[] = array($toInvoke, $args, $expectedResult);361 // 5 -------------------------------------------------------------------------------------->362 $toInvoke = array('Auryn\Test\ExecuteClassStaticMethod', 'execute');363 $args = array();364 $expectedResult = 42;365 $return[] = array($toInvoke, $args, $expectedResult);366 // 6 -------------------------------------------------------------------------------------->367 $toInvoke = array(new ExecuteClassStaticMethod, 'execute');368 $args = array();369 $expectedResult = 42;370 $return[] = array($toInvoke, $args, $expectedResult);371 // 7 -------------------------------------------------------------------------------------->372 $toInvoke = 'Auryn\Test\ExecuteClassStaticMethod::execute';373 $args = array();374 $expectedResult = 42;375 $return[] = array($toInvoke, $args, $expectedResult);376 // 8 -------------------------------------------------------------------------------------->377 $toInvoke = array('Auryn\Test\ExecuteClassRelativeStaticMethod', 'parent::execute');378 $args = array();379 $expectedResult = 42;380 $return[] = array($toInvoke, $args, $expectedResult);381 // 9 -------------------------------------------------------------------------------------->382 $toInvoke = 'Auryn\Test\testExecuteFunction';383 $args = array();384 $expectedResult = 42;385 $return[] = array($toInvoke, $args, $expectedResult);386 // 10 ------------------------------------------------------------------------------------->387 $toInvoke = function () { return 42; };388 $args = array();389 $expectedResult = 42;390 $return[] = array($toInvoke, $args, $expectedResult);391 // 11 ------------------------------------------------------------------------------------->392 $toInvoke = new ExecuteClassInvokable;393 $args = array();394 $expectedResult = 42;395 $return[] = array($toInvoke, $args, $expectedResult);396 // 12 ------------------------------------------------------------------------------------->397 $toInvoke = 'Auryn\Test\ExecuteClassInvokable';398 $args = array();399 $expectedResult = 42;400 $return[] = array($toInvoke, $args, $expectedResult);401 // 13 ------------------------------------------------------------------------------------->402 $toInvoke = 'Auryn\Test\ExecuteClassNoDeps::execute';403 $args = array();404 $expectedResult = 42;405 $return[] = array($toInvoke, $args, $expectedResult);406 // 14 ------------------------------------------------------------------------------------->407 $toInvoke = 'Auryn\Test\ExecuteClassDeps::execute';408 $args = array();409 $expectedResult = 42;410 $return[] = array($toInvoke, $args, $expectedResult);411 // 15 ------------------------------------------------------------------------------------->412 $toInvoke = 'Auryn\Test\ExecuteClassStaticMethod::execute';413 $args = array();414 $expectedResult = 42;415 $return[] = array($toInvoke, $args, $expectedResult);416 // 16 ------------------------------------------------------------------------------------->417 $toInvoke = 'Auryn\Test\ExecuteClassRelativeStaticMethod::parent::execute';418 $args = array();419 $expectedResult = 42;420 $return[] = array($toInvoke, $args, $expectedResult);421 // 17 ------------------------------------------------------------------------------------->422 $toInvoke = 'Auryn\Test\testExecuteFunctionWithArg';423 $args = array();424 $expectedResult = 42;425 $return[] = array($toInvoke, $args, $expectedResult);426 // 18 ------------------------------------------------------------------------------------->427 $toInvoke = function () {428 return 42;429 };430 $args = array();431 $expectedResult = 42;432 $return[] = array($toInvoke, $args, $expectedResult);433 if (PHP_VERSION_ID > 50400) {434 // 19 ------------------------------------------------------------------------------------->435 $object = new \Auryn\Test\ReturnsCallable('new value');436 $args = array();437 $toInvoke = $object->getCallable();438 $expectedResult = 'new value';439 $return[] = array($toInvoke, $args, $expectedResult);440 }441 // x -------------------------------------------------------------------------------------->442 return $return;443 }444 public function testStaticStringInvokableWithArgument()445 {446 $injector = new \Auryn\Injector;447 $invokable = $injector->buildExecutable('Auryn\Test\ClassWithStaticMethodThatTakesArg::doSomething');448 $this->assertEquals(42, $invokable(41));449 }450 public function testInterfaceFactoryDelegation()451 {452 $injector = new Injector;453 $injector->delegate('Auryn\Test\DelegatableInterface', 'Auryn\Test\ImplementsInterfaceFactory');454 $requiresDelegatedInterface = $injector->make('Auryn\Test\RequiresDelegatedInterface');455 $requiresDelegatedInterface->foo();456 }457 /**458 * @expectedException Auryn\InjectorException459 */460 public function testMissingAlias()461 {462 $injector = new Injector;463 $testClass = $injector->make('Auryn\Test\TestMissingDependency');464 }465 public function testAliasingConcreteClasses()466 {467 $injector = new Injector;468 $injector->alias('Auryn\Test\ConcreteClass1', 'Auryn\Test\ConcreteClass2');469 $obj = $injector->make('Auryn\Test\ConcreteClass1');470 $this->assertInstanceOf('Auryn\Test\ConcreteClass2', $obj);471 }472 public function testSharedByAliasedInterfaceName()473 {474 $injector = new Injector;475 $injector->alias('Auryn\Test\SharedAliasedInterface', 'Auryn\Test\SharedClass');476 $injector->share('Auryn\Test\SharedAliasedInterface');477 $class = $injector->make('Auryn\Test\SharedAliasedInterface');478 $class2 = $injector->make('Auryn\Test\SharedAliasedInterface');479 $this->assertSame($class, $class2);480 }481 public function testNotSharedByAliasedInterfaceName()482 {483 $injector = new Injector;484 $injector->alias('Auryn\Test\SharedAliasedInterface', 'Auryn\Test\SharedClass');485 $injector->alias('Auryn\Test\SharedAliasedInterface', 'Auryn\Test\NotSharedClass');486 $injector->share('Auryn\Test\SharedClass');487 $class = $injector->make('Auryn\Test\SharedAliasedInterface');488 $class2 = $injector->make('Auryn\Test\SharedAliasedInterface');489 $this->assertNotSame($class, $class2);490 }491 public function testSharedByAliasedInterfaceNameReversedOrder()492 {493 $injector = new Injector;494 $injector->share('Auryn\Test\SharedAliasedInterface');495 $injector->alias('Auryn\Test\SharedAliasedInterface', 'Auryn\Test\SharedClass');496 $class = $injector->make('Auryn\Test\SharedAliasedInterface');497 $class2 = $injector->make('Auryn\Test\SharedAliasedInterface');498 $this->assertSame($class, $class2);499 }500 public function testSharedByAliasedInterfaceNameWithParameter()501 {502 $injector = new Injector;503 $injector->alias('Auryn\Test\SharedAliasedInterface', 'Auryn\Test\SharedClass');504 $injector->share('Auryn\Test\SharedAliasedInterface');505 $sharedClass = $injector->make('Auryn\Test\SharedAliasedInterface');506 $childClass = $injector->make('Auryn\Test\ClassWithAliasAsParameter');507 $this->assertSame($sharedClass, $childClass->sharedClass);508 }509 public function testSharedByAliasedInstance()510 {511 $injector = new Injector;512 $injector->alias('Auryn\Test\SharedAliasedInterface', 'Auryn\Test\SharedClass');513 $sharedClass = $injector->make('Auryn\Test\SharedAliasedInterface');514 $injector->share($sharedClass);515 $childClass = $injector->make('Auryn\Test\ClassWithAliasAsParameter');516 $this->assertSame($sharedClass, $childClass->sharedClass);517 }518 public function testMultipleShareCallsDontOverrideTheOriginalSharedInstance()519 {520 $injector = new Injector;521 $injector->share('StdClass');522 $stdClass1 = $injector->make('StdClass');523 $injector->share('StdClass');524 $stdClass2 = $injector->make('StdClass');525 $this->assertSame($stdClass1, $stdClass2);526 }527 public function testDependencyWhereSharedWithProtectedConstructor()528 {529 $injector = new Injector;530 $inner = TestDependencyWithProtectedConstructor::create();531 $injector->share($inner);532 $outer = $injector->make('Auryn\Test\TestNeedsDepWithProtCons');533 $this->assertSame($inner, $outer->dep);534 }535 public function testDependencyWhereShared()536 {537 $injector = new Injector;538 $injector->share('Auryn\Test\ClassInnerB');539 $innerDep = $injector->make('Auryn\Test\ClassInnerB');540 $inner = $injector->make('Auryn\Test\ClassInnerA');541 $this->assertSame($innerDep, $inner->dep);542 $outer = $injector->make('Auryn\Test\ClassOuter');543 $this->assertSame($innerDep, $outer->dep->dep);544 }545 public function testBugWithReflectionPoolIncorrectlyReturningBadInfo()546 {547 $injector = new Injector;548 $obj = $injector->make('Auryn\Test\ClassOuter');549 $this->assertInstanceOf('Auryn\Test\ClassOuter', $obj);550 $this->assertInstanceOf('Auryn\Test\ClassInnerA', $obj->dep);551 $this->assertInstanceOf('Auryn\Test\ClassInnerB', $obj->dep->dep);552 }553 public function provideCyclicDependencies()554 {555 return array(556 'Auryn\Test\RecursiveClassA' => array('Auryn\Test\RecursiveClassA'),557 'Auryn\Test\RecursiveClassB' => array('Auryn\Test\RecursiveClassB'),558 'Auryn\Test\RecursiveClassC' => array('Auryn\Test\RecursiveClassC'),559 'Auryn\Test\RecursiveClass1' => array('Auryn\Test\RecursiveClass1'),560 'Auryn\Test\RecursiveClass2' => array('Auryn\Test\RecursiveClass2'),561 'Auryn\Test\DependsOnCyclic' => array('Auryn\Test\DependsOnCyclic'),562 );563 }564 /**565 * @dataProvider provideCyclicDependencies566 * @expectedException \Auryn\InjectionException567 * @expectedExceptionCode \Auryn\Injector::E_CYCLIC_DEPENDENCY568 */569 public function testCyclicDependencies($class)570 {571 $injector = new Injector;572 $injector->make($class);573 }574 public function testNonConcreteDependencyWithDefault()575 {576 $injector = new Injector;577 $class = $injector->make('Auryn\Test\NonConcreteDependencyWithDefaultValue');578 $this->assertInstanceOf('Auryn\Test\NonConcreteDependencyWithDefaultValue', $class);579 $this->assertNull($class->interface);580 }581 public function testNonConcreteDependencyWithDefaultValueThroughAlias()582 {583 $injector = new Injector;584 $injector->alias(585 'Auryn\Test\DelegatableInterface',586 'Auryn\Test\ImplementsInterface'587 );588 $class = $injector->make('Auryn\Test\NonConcreteDependencyWithDefaultValue');589 $this->assertInstanceOf('Auryn\Test\NonConcreteDependencyWithDefaultValue', $class);590 $this->assertInstanceOf('Auryn\Test\ImplementsInterface', $class->interface);591 }592 public function testNonConcreteDependencyWithDefaultValueThroughDelegation()593 {594 $injector = new Injector;595 $injector->delegate('Auryn\Test\DelegatableInterface', 'Auryn\Test\ImplementsInterfaceFactory');596 $class = $injector->make('Auryn\Test\NonConcreteDependencyWithDefaultValue');597 $this->assertInstanceOf('Auryn\Test\NonConcreteDependencyWithDefaultValue', $class);598 $this->assertInstanceOf('Auryn\Test\ImplementsInterface', $class->interface);599 }600 public function testDependencyWithDefaultValueThroughShare()601 {602 $injector = new Injector;603 //Instance is not shared, null default is used for dependency604 $instance = $injector->make('Auryn\Test\ConcreteDependencyWithDefaultValue');605 $this->assertNull($instance->dependency);606 //Instance is explicitly shared, $instance is used for dependency607 $instance = new \StdClass();608 $injector->share($instance);609 $instance = $injector->make('Auryn\Test\ConcreteDependencyWithDefaultValue');610 $this->assertInstanceOf('StdClass', $instance->dependency);611 }612 /**613 * @expectedException \Auryn\ConfigException614 * @expectedExceptionCode \Auryn\Injector::E_ALIASED_CANNOT_SHARE615 */616 public function testShareAfterAliasException()617 {618 $injector = new Injector();619 $testClass = new \StdClass();620 $injector->alias('StdClass', 'Auryn\Test\SomeOtherClass');621 $injector->share($testClass);622 }623 public function testShareAfterAliasAliasedClassAllowed()624 {625 $injector = new Injector();626 $testClass = new DepImplementation();627 $injector->alias('Auryn\Test\DepInterface', 'Auryn\Test\DepImplementation');628 $injector->share($testClass);629 $obj = $injector->make('Auryn\Test\DepInterface');630 $this->assertInstanceOf('Auryn\Test\DepImplementation', $obj);631 }632 public function testAliasAfterShareByStringAllowed()633 {634 $injector = new Injector();635 $injector->share('Auryn\Test\DepInterface');636 $injector->alias('Auryn\Test\DepInterface', 'Auryn\Test\DepImplementation');637 $obj = $injector->make('Auryn\Test\DepInterface');638 $obj2 = $injector->make('Auryn\Test\DepInterface');639 $this->assertInstanceOf('Auryn\Test\DepImplementation', $obj);640 $this->assertEquals($obj, $obj2);641 }642 public function testAliasAfterShareBySharingAliasAllowed()643 {644 $injector = new Injector();645 $injector->share('Auryn\Test\DepImplementation');646 $injector->alias('Auryn\Test\DepInterface', 'Auryn\Test\DepImplementation');647 $obj = $injector->make('Auryn\Test\DepInterface');648 $obj2 = $injector->make('Auryn\Test\DepInterface');649 $this->assertInstanceOf('Auryn\Test\DepImplementation', $obj);650 $this->assertEquals($obj, $obj2);651 }652 /**653 * @expectedException \Auryn\ConfigException654 * @expectedExceptionCode \Auryn\Injector::E_SHARED_CANNOT_ALIAS655 */656 public function testAliasAfterShareException()657 {658 $injector = new Injector();659 $testClass = new \StdClass();660 $injector->share($testClass);661 $injector->alias('StdClass', 'Auryn\Test\SomeOtherClass');662 }663 /**664 * @expectedException \Auryn\InjectionException665 * @expectedExceptionCode \Auryn\Injector::E_NON_PUBLIC_CONSTRUCTOR666 */667 public function testAppropriateExceptionThrownOnNonPublicConstructor()668 {669 $injector = new Injector();670 $injector->make('Auryn\Test\HasNonPublicConstructor');671 }672 /**673 * @expectedException \Auryn\InjectionException674 * @expectedExceptionCode \Auryn\Injector::E_NON_PUBLIC_CONSTRUCTOR675 */676 public function testAppropriateExceptionThrownOnNonPublicConstructorWithArgs()677 {678 $injector = new Injector();679 $injector->make('Auryn\Test\HasNonPublicConstructorWithArgs');680 }681 public function testMakeExecutableFailsOnNonExistentFunction()682 {683 $injector = new Injector();684 $this->setExpectedException(685 'Auryn\InjectionException',686 'nonExistentFunction',687 \Auryn\Injector::E_INVOKABLE688 );689 $injector->buildExecutable('nonExistentFunction');690 }691 public function testMakeExecutableFailsOnNonExistentInstanceMethod()692 {693 $injector = new Injector();694 $object = new \StdClass();695 $this->setExpectedException(696 'Auryn\InjectionException',697 "[object(stdClass), 'nonExistentMethod']",698 \Auryn\Injector::E_INVOKABLE699 );700 $injector->buildExecutable(array($object, 'nonExistentMethod'));701 }702 703 public function testMakeExecutableFailsOnNonExistentStaticMethod()704 {705 $injector = new Injector();706 $this->setExpectedException(707 'Auryn\InjectionException',708 "StdClass::nonExistentMethod",709 \Auryn\Injector::E_INVOKABLE710 );711 $injector->buildExecutable(array('StdClass', 'nonExistentMethod'));712 }713 /**714 * @expectedException \Auryn\InjectionException715 * @expectedExceptionCode \Auryn\Injector::E_INVOKABLE716 */717 public function testMakeExecutableFailsOnClassWithoutInvoke()718 {719 $injector = new Injector();720 $object = new \StdClass();721 $injector->buildExecutable($object);722 }723 /**724 * @expectedException \Auryn\ConfigException725 * @expectedExceptionCode \Auryn\Injector::E_NON_EMPTY_STRING_ALIAS726 */727 public function testBadAlias()728 {729 $injector = new Injector();730 $injector->share('Auryn\Test\DepInterface');731 $injector->alias('Auryn\Test\DepInterface', '');732 }733 public function testShareNewAlias()734 {735 $injector = new Injector();736 $injector->share('Auryn\Test\DepImplementation');737 $injector->alias('Auryn\Test\DepInterface', 'Auryn\Test\DepImplementation');738 }739 public function testDefineWithBackslashAndMakeWithoutBackslash()740 {741 $injector = new Injector();742 $injector->define('Auryn\Test\SimpleNoTypehintClass', array(':arg' => 'tested'));743 $testClass = $injector->make('Auryn\Test\SimpleNoTypehintClass');744 $this->assertEquals('tested', $testClass->testParam);745 }746 public function testShareWithBackslashAndMakeWithoutBackslash()747 {748 $injector = new Injector();749 $injector->share('\StdClass');750 $classA = $injector->make('StdClass');751 $classA->tested = false;752 $classB = $injector->make('\StdClass');753 $classB->tested = true;754 $this->assertEquals($classA->tested, $classB->tested);755 }756 public function testInstanceMutate()757 {758 $injector = new Injector();759 $injector->prepare('\StdClass', function ($obj, $injector) {760 $obj->testval = 42;761 });762 $obj = $injector->make('StdClass');763 $this->assertSame(42, $obj->testval);764 }765 public function testInterfaceMutate()766 {767 $injector = new Injector();768 $injector->prepare('Auryn\Test\SomeInterface', function ($obj, $injector) {769 $obj->testProp = 42;770 });771 $obj = $injector->make('Auryn\Test\PreparesImplementationTest');772 $this->assertSame(42, $obj->testProp);773 }774 /**775 * Test that custom definitions are not passed through to dependencies.776 * Surprising things would happen if this did occur.777 * @expectedException \Auryn\InjectionException778 * @expectedExceptionCode \Auryn\Injector::E_UNDEFINED_PARAM779 */780 public function testCustomDefinitionNotPassedThrough()781 {782 $injector = new Injector();783 $injector->share('Auryn\Test\DependencyWithDefinedParam');784 $injector->make('Auryn\Test\RequiresDependencyWithDefinedParam', array(':foo' => 5));785 }786 public function testDelegationFunction()787 {788 $injector = new Injector();789 $injector->delegate('Auryn\Test\TestDelegationSimple', 'Auryn\Test\createTestDelegationSimple');790 $obj = $injector->make('Auryn\Test\TestDelegationSimple');791 $this->assertInstanceOf('Auryn\Test\TestDelegationSimple', $obj);792 $this->assertTrue($obj->delegateCalled);793 }794 public function testDelegationDependency()795 {796 $injector = new Injector();797 $injector->delegate(798 'Auryn\Test\TestDelegationDependency',799 'Auryn\Test\createTestDelegationDependency'800 );801 $obj = $injector->make('Auryn\Test\TestDelegationDependency');802 $this->assertInstanceOf('Auryn\Test\TestDelegationDependency', $obj);803 $this->assertTrue($obj->delegateCalled);804 }805 public function testExecutableAliasing()806 {807 $injector = new Injector();808 $injector->alias('Auryn\Test\BaseExecutableClass', 'Auryn\Test\ExtendsExecutableClass');809 $result = $injector->execute(array('Auryn\Test\BaseExecutableClass', 'foo'));810 $this->assertEquals('This is the ExtendsExecutableClass', $result);811 }812 public function testExecutableAliasingStatic()813 {814 $injector = new Injector();815 $injector->alias('Auryn\Test\BaseExecutableClass', 'Auryn\Test\ExtendsExecutableClass');816 $result = $injector->execute(array('Auryn\Test\BaseExecutableClass', 'bar'));817 $this->assertEquals('This is the ExtendsExecutableClass', $result);818 }819 /**820 * Test coverage for delegate closures that are defined outside821 * of a class.ph822 * @throws \Auryn\ConfigException823 */824 public function testDelegateClosure()825 {826 $delegateClosure = \Auryn\Test\getDelegateClosureInGlobalScope();827 $injector = new Injector();828 $injector->delegate('Auryn\Test\DelegateClosureInGlobalScope', $delegateClosure);829 $injector->make('Auryn\Test\DelegateClosureInGlobalScope');830 }831 public function testCloningWithServiceLocator()832 {833 $injector = new Injector();834 $injector->share($injector);835 $instance = $injector->make('Auryn\Test\CloneTest');836 $newInjector = $instance->injector;837 $newInstance = $newInjector->make('Auryn\Test\CloneTest');838 }839 public function testAbstractExecute()840 {841 $injector = new Injector();842 $fn = function () {843 return new \Auryn\Test\ConcreteExexcuteTest();844 };845 $injector->delegate('Auryn\Test\AbstractExecuteTest', $fn);846 $result = $injector->execute(array('Auryn\Test\AbstractExecuteTest', 'process'));847 $this->assertEquals('Concrete', $result);848 }849 public function testDebugMake()850 {851 $injector = new Injector();852 try {853 $injector->make('Auryn\Test\DependencyChainTest');854 } catch (\Auryn\InjectionException $ie) {855 $chain = $ie->getDependencyChain();856 $this->assertCount(2, $chain);857 $this->assertEquals('auryn\test\dependencychaintest', $chain[0]);858 $this->assertEquals('auryn\test\depinterface', $chain[1]);859 }860 }861 public function testInspectShares()862 {863 $injector = new Injector();864 $injector->share('Auryn\Test\SomeClassName');865 $inspection = $injector->inspect('Auryn\Test\SomeClassName', Injector::I_SHARES);866 $this->assertArrayHasKey('auryn\test\someclassname', $inspection[Injector::I_SHARES]);867 }868 /**869 * @expectedException \Auryn\InjectionException870 * @expectedExceptionCode \Auryn\Injector::E_MAKING_FAILED871 */872 public function testDelegationDoesntMakeObject()873 {874 $delegate = function () {875 return null;876 };877 $injector = new Injector();878 $injector->delegate('Auryn\Test\SomeClassName', $delegate);879 $injector->make('Auryn\Test\SomeClassName');880 }881 /**882 * @expectedException \Auryn\InjectionException883 * @expectedExceptionCode \Auryn\Injector::E_MAKING_FAILED884 */885 public function testDelegationDoesntMakeObjectMakesString()886 {887 $delegate = function () {888 return 'ThisIsNotAClass';889 };890 $injector = new Injector();891 $injector->delegate('Auryn\Test\SomeClassName', $delegate);892 $injector->make('Auryn\Test\SomeClassName');893 }894 public function testPrepareCallableReplacesObjectWithReturnValueOfSameInterfaceType()895 {896 $injector = new Injector;897 $expected = new SomeImplementation; // <-- implements SomeInterface898 $injector->prepare("Auryn\Test\SomeInterface", function ($impl) use ($expected) {899 return $expected;900 });901 $actual = $injector->make("Auryn\Test\SomeImplementation");902 $this->assertSame($expected, $actual);903 }904 public function testPrepareCallableReplacesObjectWithReturnValueOfSameClassType()905 {906 $injector = new Injector;907 $expected = new SomeImplementation; // <-- implements SomeInterface908 $injector->prepare("Auryn\Test\SomeImplementation", function ($impl) use ($expected) {909 return $expected;910 });911 $actual = $injector->make("Auryn\Test\SomeImplementation");912 $this->assertSame($expected, $actual);913 }914 public function testChildWithoutConstructorWorks() {915 $injector = new Injector;916 try {917 $injector->define('Auryn\Test\ParentWithConstructor', array(':foo' => 'parent'));918 $injector->define('Auryn\Test\ChildWithoutConstructor', array(':foo' => 'child'));919 920 $injector->share('Auryn\Test\ParentWithConstructor');921 $injector->share('Auryn\Test\ChildWithoutConstructor');922 $child = $injector->make('Auryn\Test\ChildWithoutConstructor');923 $this->assertEquals('child', $child->foo);924 $parent = $injector->make('Auryn\Test\ParentWithConstructor');925 $this->assertEquals('parent', $parent->foo);926 }927 catch (\Auryn\InjectionException $ie) {928 echo $ie->getMessage();929 $this->fail("Auryn failed to locate the ");930 }931 }932 933 /**934 * @expectedException \Auryn\InjectionException935 * @expectedExceptionCode \Auryn\Injector::E_UNDEFINED_PARAM936 */937 public function testChildWithoutConstructorMissingParam() {938 $injector = new Injector;939 $injector->define('Auryn\Test\ParentWithConstructor', array(':foo' => 'parent'));940 $injector->make('Auryn\Test\ChildWithoutConstructor');941 }942}...

Full Screen

Full Screen

AssetInjectorJs.php

Source:AssetInjectorJs.php Github

copy

Full Screen

1<?php2namespace Drupal\asset_injector\Entity;3/**4 * Defines the Js Injector entity.5 *6 * @ConfigEntityType(7 * id = "asset_injector_js",8 * label = @Translation("Js Injector"),9 * list_cache_tags = { "library_info" },10 * handlers = {11 * "access" = "Drupal\asset_injector\AssetInjectorAccessControlHandler",12 * "list_builder" = "Drupal\asset_injector\AssetInjectorListBuilder",13 * "form" = {14 * "add" = "Drupal\asset_injector\Form\AssetInjectorJsForm",15 * "edit" = "Drupal\asset_injector\Form\AssetInjectorJsForm",16 * "delete" = "Drupal\asset_injector\Form\AssetInjectorDeleteForm",17 * "enable" = "Drupal\asset_injector\Form\AssetInjectorEnableForm",18 * "disable" = "Drupal\asset_injector\Form\AssetInjectorDisableForm",19 * "duplicate" = "Drupal\asset_injector\Form\AssetInjectorJsDuplicateForm",20 * }21 * },22 * config_prefix = "js",23 * admin_permission = "administer js assets injector",24 * entity_keys = {25 * "id" = "id",26 * "label" = "label",27 * "status" = "status",28 * },29 * links = {30 * "canonical" = "/admin/config/development/asset-injector/js/{asset_injector_js}",31 * "edit-form" = "/admin/config/development/asset-injector/js/{asset_injector_js}",32 * "delete-form" = "/admin/config/development/asset-injector/js/{asset_injector_js}/delete",33 * "enable" = "/admin/config/development/asset-injector/js/{asset_injector_js}/enable",34 * "disable" = "/admin/config/development/asset-injector/js/{asset_injector_js}/disable",35 * "collection" = "/admin/structure/conditions_group"36 * },37 * config_export = {38 * "id",39 * "label",40 * "code",41 * "conditions_require_all",42 * "conditions",43 * "contexts",44 * "header",45 * "preprocess",46 * "jquery",47 * "noscript",48 * "noscriptRegion"...

Full Screen

Full Screen

AssetInjectorCss.php

Source:AssetInjectorCss.php Github

copy

Full Screen

1<?php2namespace Drupal\asset_injector\Entity;3/**4 * Defines the CSS Injector entity.5 *6 * @ConfigEntityType(7 * id = "asset_injector_css",8 * label = @Translation("CSS Injector"),9 * list_cache_tags = { "library_info" },10 * handlers = {11 * "access" = "Drupal\asset_injector\AssetInjectorAccessControlHandler",12 * "list_builder" = "Drupal\asset_injector\AssetInjectorListBuilder",13 * "form" = {14 * "add" = "Drupal\asset_injector\Form\AssetInjectorCssForm",15 * "edit" = "Drupal\asset_injector\Form\AssetInjectorCssForm",16 * "delete" = "Drupal\asset_injector\Form\AssetInjectorDeleteForm",17 * "enable" = "Drupal\asset_injector\Form\AssetInjectorEnableForm",18 * "disable" = "Drupal\asset_injector\Form\AssetInjectorDisableForm",19 * "duplicate" = "Drupal\asset_injector\Form\AssetInjectorCssDuplicateForm",20 * },21 * },22 * config_prefix = "css",23 * admin_permission = "administer css assets injector",24 * entity_keys = {25 * "id" = "id",26 * "label" = "label",27 * "status" = "status",28 * },29 * links = {30 * "canonical" = "/admin/config/development/asset-injector/css/{asset_injector_css}",31 * "edit-form" = "/admin/config/development/asset-injector/css/{asset_injector_css}",32 * "delete-form" = "/admin/config/development/asset-injector/css/{asset_injector_css}/delete",33 * "enable" = "/admin/config/development/asset-injector/css/{asset_injector_css}/enable",34 * "disable" = "/admin/config/development/asset-injector/css/{asset_injector_css}/disable",35 * "collection" = "/admin/structure/conditions_group"36 * },37 * config_export = {38 * "id",39 * "label",40 * "code",41 * "conditions_require_all",42 * "conditions",43 * "contexts",44 * "media",45 * "preprocess"46 * }47 * )48 */...

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1use mageekguy\atoum\asserters\phpString;2use mageekguy\atoum\asserters\phpArray;3use mageekguy\atoum\asserters\phpObject;4use mageekguy\atoum\asserters\variable;5use mageekguy\atoum\asserters\exception;6use mageekguy\atoum\asserters\integer;7use mageekguy\atoum\asserters\output;8use mageekguy\atoum\asserters\phpFloat;9use mageekguy\atoum\asserters\phpResource;10use mageekguy\atoum\asserters\phpClass;11use mageekguy\atoum\asserters\phpFunction;12use mageekguy\atoum\asserters\phpConstant;13use mageekguy\atoum\asserters\phpVariable;14use mageekguy\atoum\asserters\phpGenerator;15use mageekguy\atoum\asserters\phpFunction\call;16use mageekguy\atoum\asserters\phpFunction\call\adapter;17use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker;18use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception;19use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception\logic;20use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception\invalidArgument;21use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception\logic\invalidArgument;22use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception\logic\invalidArgument\invalidType;23use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception\logic\invalidArgument\invalidType\invalidClass;24use mageekguy\atoum\asserters\phpFunction\call\adapter\invoker\exception\logic\invalidArgument\invalidType\invalidInterface;

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1$injector = new \mageekguy\atoum\mock\php\aggregator();2$asserterGenerator = new \mageekguy\atoum\asserter\generator();3$asserterGenerator->setWithTest($this);4$mockGenerator = new \mageekguy\atoum\mock\generator();5$mockGenerator->setWithTest($this);6$mockGenerator->setInjector($injector);7$test = new \mageekguy\atoum\test();8$test->setAssertionManager(new \mageekguy\atoum\assertion\manager());9$test->setLocale(new \mageekguy\atoum\locale());10$test->setScore(new \mageekguy\atoum\score());11$test->setMockGenerator($mockGenerator);12$test->setAsserterGenerator($asserterGenerator);13$test->setAssertionManager(new \mageekguy\atoum\assertion\manager());14$test->setLocale(new \mageekguy\atoum\locale());15$test->setScore(new \mageekguy\atoum\score());16$test->setMockGenerator($mockGenerator);17$test->setAsserterGenerator($asserterGenerator);18$test->setAssertionManager(new \mageekguy\atoum\assertion\manager());19$test->setLocale(new \mageekguy\atoum\locale());20$test->setScore(new \mageekguy\atoum\score());21$test->setMockGenerator($mockGenerator);22$test->setAsserterGenerator($asserterGenerator);23$test->setAssertionManager(new \mageekguy\atoum\assertion\manager());24$test->setLocale(new \mageekguy\atoum\locale());25$test->setScore(new \mageekguy\atoum\score());26$test->setMockGenerator($mockGenerator);27$test->setAsserterGenerator($asser

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1$injector = new \mageekguy\atoum\mock\php\call\aggregator\injector();2$mock = new \mageekguy\atoum\mock\php\call\aggregator\mock();3$mock->setInjector($injector);4$mock->getMockController()->getFoo = 42;5$injector = new \mageekguy\atoum\mock\php\call\aggregator\injector();6$mock = new \mageekguy\atoum\mock\php\call\aggregator\mock();7$mock->setInjector($injector);8$mock->getMockController()->getFoo = 42;9$injector = new \mageekguy\atoum\mock\php\call\aggregator\injector();10$mock = new \mageekguy\atoum\mock\php\call\aggregator\mock();11$mock->setInjector($injector);12$mock->getMockController()->getFoo = 42;13$injector = new \mageekguy\atoum\mock\php\call\aggregator\injector();14$mock = new \mageekguy\atoum\mock\php\call\aggregator\mock();15$mock->setInjector($injector);16$mock->getMockController()->getFoo = 42;17$mock->getFoo;

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1$php = new \mageekguy\atoum\php\mocker\generator();2$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());3$php = new \mageekguy\atoum\php\mocker\generator();4$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());5$php = new \mageekguy\atoum\php\mocker\generator();6$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());7$php = new \mageekguy\atoum\php\mocker\generator();8$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());9$php = new \mageekguy\atoum\php\mocker\generator();10$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());11$php = new \mageekguy\atoum\php\mocker\generator();12$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());13$php = new \mageekguy\atoum\php\mocker\generator();14$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());15$php = new \mageekguy\atoum\php\mocker\generator();16$php->setCallInjector(new \mageekguy\atoum\php\mocker\callInjector());

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1$injector = new \atoum\injector();2$injector->set($mock);3$injector = new \atoum\injector();4$injector->set($mock);5$injector = new \atoum\injector();6$injector->set($mock);7$injector = new \atoum\injector();8$injector->set($mock);9$injector = new \atoum\injector();10$injector->set($mock);11$injector = new \atoum\injector();12$injector->set($mock);13$injector = new \atoum\injector();14$injector->set($mock);15$injector = new \atoum\injector();16$injector->set($mock);17$injector = new \atoum\injector();18$injector->set($mock);19$injector = new \atoum\injector();20$injector->set($mock);21$injector = new \atoum\injector();22$injector->set($mock);23$injector = new \atoum\injector();24$injector->set($mock);25$injector = new \atoum\injector();26$injector->set($mock);

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1$injector = new atoum\injector();2$injector->setClass('myClass', 'myClassMock');3$injector->setClass('myClass2', 'myClass2Mock');4$injector->setClass('myClass3', 'myClass3Mock');5$injector->register();6$injector = new atoum\injector();7$injector->setClass('myClass', 'myClassMock');8$injector->setClass('myClass2', 'myClass2Mock');9$injector->setClass('myClass3', 'myClass3Mock');10$injector->register();11$injector = new atoum\injector();12$injector->setClass('myClass', 'myClassMock');13$injector->setClass('myClass2', 'myClass2Mock');14$injector->setClass('myClass3', 'myClass3Mock');15$injector->register();16$injector = new atoum\injector();17$injector->setClass('myClass', 'myClassMock');18$injector->setClass('myClass2', 'myClass2Mock');19$injector->setClass('myClass3', 'myClass3Mock');20$injector->register();21$injector = new atoum\injector();22$injector->setClass('myClass', 'myClassMock');23$injector->setClass('myClass2', 'myClass2Mock');24$injector->setClass('myClass3', 'myClass3Mock');25$injector->register();26$injector = new atoum\injector();27$injector->setClass('myClass', 'myClassMock');28$injector->setClass('myClass2', 'myClass2Mock');29$injector->setClass('myClass3', 'myClass3Mock');30$injector->register();

Full Screen

Full Screen

injector

Using AI Code Generation

copy

Full Screen

1$injector = new \mageekguy\atoum\mock\php\call\injector();2$injector->setFunction('myFunction', function () {3 return 'test';4});5$injector->setFunction('myOtherFunction', function () {6 return 'test2';7});8$injector->restoreFunction('myFunction');9$injector->restoreFunction('myOtherFunction');10$injector = new \mageekguy\atoum\mock\php\call\injector();11$injector->setFunction('myFunction', function () {12 return 'test';13});14$injector->restoreFunction('myFunction');15$injector = new \mageekguy\atoum\mock\php\call\injector();16$injector->setFunction('myOtherFunction', function () {17 return 'test2';18});19$injector->restoreFunction('myOtherFunction');20$injector = new \mageekguy\atoum\mock\php\call\injector();21$injector->setFunction('myFunction', function () {22 return 'test';23});24$injector->setFunction('myOtherFunction', function () {25 return 'test2';26});27$injector->restoreFunction('myFunction');28$injector->restoreFunction('myOtherFunction');

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful