18 private $connectionMock;
28 private $profileFactory;
60 $this->connectionMock = $this->getMockForAbstractClass(
61 \
Magento\Framework\DB\Adapter\AdapterInterface::class,
70 $this->profileFactory = $this->createPartialMock(
71 \
Magento\SalesSequence\Model\ProfileFactory::class,
74 $this->resourceMock = $this->createPartialMock(
75 \
Magento\Framework\
App\ResourceConnection::class,
76 [
'getConnection',
'getTableName']
78 $this->dbContext->expects($this->once())->method(
'getResources')->willReturn($this->resourceMock);
79 $this->select = $this->createMock(\
Magento\Framework\DB\Select::class);
80 $this->meta = $this->createMock(\
Magento\SalesSequence\Model\Meta::class);
81 $this->profile = $this->createMock(\
Magento\SalesSequence\Model\Profile::class);
90 $profileTableName =
'sequence_profile';
91 $profileIdFieldName =
'profile_id';
98 $this->profileFactory->expects($this->once())->method(
'create')->willReturn($this->profile);
99 $this->resourceMock->expects($this->any())
100 ->method(
'getConnection')
101 ->willReturn($this->connectionMock);
102 $this->resourceMock->expects($this->once())
103 ->method(
'getTableName')
104 ->willReturn($profileTableName);
105 $this->connectionMock->expects($this->any())->method(
'select')->willReturn($this->select);
106 $this->select->expects($this->at(0))
108 ->with($profileTableName, [$profileIdFieldName])
109 ->willReturn($this->select);
110 $this->select->expects($this->at(1))
112 ->with(
'meta_id = :meta_id')
113 ->willReturn($this->select);
114 $this->select->expects($this->at(2))
116 ->with(
'is_active = 1')
117 ->willReturn($this->select);
118 $this->connectionMock->expects($this->once())
120 ->with($this->select, [
'meta_id' => $metaId])
121 ->willReturn($profileId);
122 $this->select->expects($this->at(3))
124 ->with($profileTableName,
'*',
null)
125 ->willReturn($this->select);
126 $this->connectionMock->expects($this->any())
127 ->method(
'quoteIdentifier');
128 $this->connectionMock->expects($this->once())->method(
'fetchRow')->willReturn($profileData);
129 $this->profile->expects($this->at(1))->method(
'setData')->with($profileData);
130 $this->assertEquals($this->profile, $this->resource->loadActiveProfile($metaId));