Пример #1
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->factoryMock = $this->getMockBuilder(ModifierFactory::class)->disableOriginalConstructor()->getMock();
     $this->dataProviderMockOne = $this->getMockBuilder(ModifierInterface::class)->setMethods(['getData', 'getMeta', 'setData', 'setMeta'])->getMockForAbstractClass();
     $this->dataProviderMockTwo = clone $this->dataProviderMockOne;
     $this->factoryMock->expects($this->any())->method('create')->willReturnMap([['DataProviderMockOne', [], $this->dataProviderMockOne], ['DataProviderMockTwo', [], $this->dataProviderMockTwo]]);
 }
Пример #2
0
 /**
  * Retrieve modifiers instantiated
  *
  * @return ModifierInterface[]
  * @throws LocalizedException
  */
 public function getModifiersInstances()
 {
     if ($this->modifiersInstances) {
         return $this->modifiersInstances;
     }
     foreach ($this->modifiers as $modifier) {
         if (empty($modifier['class'])) {
             throw new LocalizedException(__('Parameter "class" must be present.'));
         }
         if (empty($modifier['sortOrder'])) {
             throw new LocalizedException(__('Parameter "sortOrder" must be present.'));
         }
         $this->modifiersInstances[$modifier['class']] = $this->factory->create($modifier['class']);
     }
     return $this->modifiersInstances;
 }
 /**
  * Get modifiers list
  *
  * @return ModifierInterface[]
  */
 protected function getModifiers()
 {
     if (empty($this->modifiersInstances)) {
         foreach ($this->modifiers as $modifierClass) {
             $this->modifiersInstances[$modifierClass] = $this->modifierFactory->create($modifierClass);
         }
     }
     return $this->modifiersInstances;
 }
Пример #4
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testCreateWithException()
 {
     $this->objectManagerMock->expects($this->once())->method('create')->willReturn(null);
     $this->model->create('');
 }
Пример #5
0
 /**
  * @return void
  */
 protected function initModifiers()
 {
     $this->modifierMock = $this->getMockBuilder('StdClass')->setMethods(['modifyData', 'modifyMeta'])->getMock();
     $this->modifierFactoryMock->expects($this->once())->method('create')->with('namespase\\SomeClass')->willReturn($this->modifierMock);
 }