コード例 #1
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Invalid value of "0" provided for the skeletonId field.
  */
 public function testCreateThrowsExceptionIfGivenSkeletonIdIsInvalid()
 {
     $skeletonId = 0;
     $entityTypeCode = 'catalog_product';
     $attributeSetMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute\\Set', ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'], [], '', false);
     $this->repositoryMock->expects($this->never())->method('save')->with($attributeSetMock);
     $attributeSetMock->expects($this->never())->method('initFromSkeleton')->with($skeletonId);
     $this->model->create($entityTypeCode, $attributeSetMock, $skeletonId);
 }
コード例 #2
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Wrong attribute properties
  */
 public function testCreateThrowsExceptionIfAttributeSetNotValid()
 {
     $entityTypeId = 4;
     $skeletonId = 5;
     $entityTypeCode = 'catalog_product';
     $attributeSetMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute\\Set', ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'], [], '', false);
     $entityTypeMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $entityTypeMock->expects($this->any())->method('getId')->will($this->returnValue($entityTypeId));
     $this->eavConfigMock->expects($this->once())->method('getEntityType')->with($entityTypeCode)->will($this->returnValue($entityTypeMock));
     $attributeSetMock->expects($this->once())->method('setEntityTypeId')->with($entityTypeId);
     $attributeSetMock->expects($this->once())->method('validate')->willThrowException(new \Exception('Wrong attribute properties'));
     $this->repositoryMock->expects($this->never())->method('save')->with($attributeSetMock);
     $attributeSetMock->expects($this->never())->method('initFromSkeleton')->with($skeletonId);
     $this->model->create($entityTypeCode, $attributeSetMock, $skeletonId);
 }