Пример #1
0
 public function testLoadActiveProfile()
 {
     $profileTableName = 'sequence_profile';
     $profileIdFieldName = 'profile_id';
     $metaId = 1;
     $profileId = 20;
     $profileData = ['profile_id' => 20, 'meta_id' => 1];
     $this->profileFactory->expects($this->once())->method('create')->willReturn($this->profile);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->resourceMock->expects($this->once())->method('getTableName')->willReturn($profileTableName);
     $this->connectionMock->expects($this->any())->method('select')->willReturn($this->select);
     $this->select->expects($this->at(0))->method('from')->with($profileTableName, [$profileIdFieldName])->willReturn($this->select);
     $this->select->expects($this->at(1))->method('where')->with('meta_id = :meta_id')->willReturn($this->select);
     $this->select->expects($this->at(2))->method('where')->with('is_active = 1')->willReturn($this->select);
     $this->connectionMock->expects($this->once())->method('fetchOne')->with($this->select, ['meta_id' => $metaId])->willReturn($profileId);
     $this->select->expects($this->at(3))->method('from')->with($profileTableName, '*', null)->willReturn($this->select);
     $this->connectionMock->expects($this->any())->method('quoteIdentifier');
     $this->connectionMock->expects($this->once())->method('fetchRow')->willReturn($profileData);
     $this->profile->expects($this->at(0))->method('setData')->with($profileData);
     $this->assertEquals($this->profile, $this->resource->loadActiveProfile($metaId));
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $profile = $object->getData('active_profile')->setMetaId($object->getId());
     $this->resourceProfile->save($profile);
     return $this;
 }