public function testCreateUsingReflection() { $type = 'Magento\\Framework\\ObjectManager\\Factory\\Fixture\\Polymorphous'; $definitions = $this->getMockForAbstractClass('\\Magento\\Framework\\ObjectManager\\Definition'); // should be more than defined in "switch" of create() method $definitions->expects($this->once())->method('getParameters')->with($type)->will($this->returnValue(array(array('one', null, false, null), array('two', null, false, null), array('three', null, false, null), array('four', null, false, null), array('five', null, false, null), array('six', null, false, null), array('seven', null, false, null), array('eight', null, false, null), array('nine', null, false, null), array('ten', null, false, null)))); $factory = new Factory($this->config, null, $definitions); $result = $factory->create($type, array('one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10)); $this->assertSame(10, $result->getArg(9)); }
/** * @constructor * * @param \Magento\Framework\ObjectManager\Config $config * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\ObjectManager\Definition $definitions * @param array $globalArguments */ public function __construct(\Magento\Framework\ObjectManager\Config $config, \Magento\Framework\ObjectManager $objectManager = null, \Magento\Framework\ObjectManager\Definition $definitions = null, $globalArguments = array()) { parent::__construct($config, $objectManager, $definitions, $globalArguments); $this->classReader = new ClassReader(); }
/** * @param string $startingClass * @param string $terminationClass * @dataProvider circularDataProvider */ public function testCircular($startingClass, $terminationClass) { $this->setExpectedException('\\LogicException', sprintf('Circular dependency: %s depends on %s and vice versa.', $startingClass, $terminationClass)); $this->factory->create($startingClass); }