Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 745c11e

Browse files
committed
MAGETWO-70985: Deprecate Repository generation logic and Materialize Repositories being generated now
- Marked repository generator as deprecated - Implemented auto-generated repositories - Marked methods as deprecated for AbstractMethod class
1 parent b2797e5 commit 745c11e

File tree

12 files changed

+81
-127
lines changed

12 files changed

+81
-127
lines changed

Block/Adminhtml/CaseInfoTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testModuleIsInactive()
5151
{
5252
$this->order->loadByIncrementId('100000001');
5353

54-
static::assertNotEmpty($this->getBlock()->toHtml());
54+
self::assertNotEmpty($this->getBlock()->toHtml());
5555
}
5656

5757
/**
@@ -67,7 +67,7 @@ public function testCaseEntityNotExists()
6767
{
6868
$this->order->loadByIncrementId('100000001');
6969

70-
static::assertEmpty($this->getBlock()->toHtml());
70+
self::assertEmpty($this->getBlock()->toHtml());
7171
}
7272

7373
/**
@@ -85,8 +85,8 @@ public function testCaseEntityExists()
8585
$this->order->loadByIncrementId('100000001');
8686

8787
$block = $this->getBlock();
88-
static::assertNotEmpty($block->toHtml());
89-
static::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
88+
self::assertNotEmpty($block->toHtml());
89+
self::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
9090
}
9191

9292
/**

Block/FingerprintTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function setUp()
3535
*/
3636
public function testSessionIdPresent()
3737
{
38-
static::assertContains('data-order-session-id', $this->getBlockContents());
38+
self::assertContains('data-order-session-id', $this->getBlockContents());
3939
}
4040

4141
/**
@@ -45,7 +45,7 @@ public function testSessionIdPresent()
4545
*/
4646
public function testBlockEmpty()
4747
{
48-
static::assertEmpty($this->getBlockContents());
48+
self::assertEmpty($this->getBlockContents());
4949
}
5050

5151
/**

Controller/Webhooks/HandlerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ public function testExecuteSuccess()
4545
$caseEntity = $caseRepository->getByCaseId($caseId);
4646
$orderEntityId = $caseEntity->getOrderId();
4747

48-
static::assertNotEmpty($caseEntity);
49-
static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
50-
static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
51-
static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
52-
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
53-
static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
54-
static::assertEquals($orderEntityId, $caseEntity->getOrderId());
48+
self::assertNotEmpty($caseEntity);
49+
self::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
50+
self::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
51+
self::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
52+
self::assertEquals(true, $caseEntity->isGuaranteeEligible());
53+
self::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
54+
self::assertEquals($orderEntityId, $caseEntity->getOrderId());
5555

5656
/** @var OrderRepositoryInterface $orderRepository */
5757
$orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
5858
$order = $orderRepository->get($caseEntity->getOrderId());
5959
$histories = $order->getStatusHistories();
60-
static::assertNotEmpty($histories);
60+
self::assertNotEmpty($histories);
6161

6262
/** @var OrderStatusHistoryInterface $caseCreationComment */
6363
$caseComment = array_pop($histories);
64-
static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
64+
self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
6565

66-
static::assertEquals(
66+
self::assertEquals(
6767
"Case Update: New score for the order is 384. Previous score was 553.",
6868
$caseComment->getComment()
6969
);

Model/CaseManagementTest.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\Signifyd\Model;
77

8-
use Magento\Framework\Api\FilterBuilder;
98
use Magento\Framework\Api\SearchCriteriaBuilder;
109
use Magento\Framework\App\ObjectManager;
1110
use Magento\Sales\Api\Data\OrderInterface;
@@ -43,9 +42,9 @@ public function testCreate()
4342
$order = $this->getOrder();
4443
$case = $this->caseManagement->create($order->getEntityId());
4544

46-
static::assertNotEmpty($case->getEntityId());
47-
static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
48-
static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
45+
self::assertNotEmpty($case->getEntityId());
46+
self::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
47+
self::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
4948
}
5049

5150
/**
@@ -57,10 +56,10 @@ public function testGetByOrderId()
5756
$order = $this->getOrder();
5857
$case = $this->caseManagement->getByOrderId($order->getEntityId());
5958

60-
static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
61-
static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
62-
static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
63-
static::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
59+
self::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
60+
self::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
61+
self::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
62+
self::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
6463
}
6564

6665
/**
@@ -69,17 +68,9 @@ public function testGetByOrderId()
6968
*/
7069
private function getOrder()
7170
{
72-
/** @var FilterBuilder $filterBuilder */
73-
$filterBuilder = $this->objectManager->get(FilterBuilder::class);
74-
$filters = [
75-
$filterBuilder->setField(OrderInterface::INCREMENT_ID)
76-
->setValue('100000001')
77-
->create()
78-
];
79-
8071
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
8172
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
82-
$searchCriteria = $searchCriteriaBuilder->addFilters($filters)
73+
$searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
8374
->create();
8475

8576
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);

Model/CaseRepositoryTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testDelete()
6565
$case = array_pop($cases);
6666
$this->repository->delete($case);
6767

68-
static::assertEmpty($this->repository->getList($searchCriteria)->getItems());
68+
self::assertEmpty($this->repository->getList($searchCriteria)->getItems());
6969
}
7070

7171
/**
@@ -87,9 +87,9 @@ public function testGetById()
8787

8888
$found = $this->repository->getById($case->getEntityId());
8989

90-
static::assertNotEmpty($found->getEntityId());
91-
static::assertEquals($case->getEntityId(), $found->getEntityId());
92-
static::assertEquals($case->getOrderId(), $found->getOrderId());
90+
self::assertNotEmpty($found->getEntityId());
91+
self::assertEquals($case->getEntityId(), $found->getEntityId());
92+
self::assertEquals($case->getOrderId(), $found->getOrderId());
9393
}
9494

9595
/**
@@ -116,11 +116,11 @@ public function testGetListDateInterval()
116116
$items = $this->repository->getList($searchCriteria)
117117
->getItems();
118118

119-
static::assertCount(3, $items);
119+
self::assertCount(3, $items);
120120

121121
for ($i = 1; $i < 4; $i ++) {
122122
$current = array_shift($items);
123-
static::assertEquals($i, $current->getCaseId());
123+
self::assertEquals($i, $current->getCaseId());
124124
}
125125
}
126126

@@ -140,9 +140,9 @@ public function testGetListStatusProcessing()
140140
$items = $this->repository->getList($searchCriteria)
141141
->getItems();
142142

143-
static::assertCount(1, $items);
143+
self::assertCount(1, $items);
144144

145145
$case = array_pop($items);
146-
static::assertEquals(123, $case->getCaseId());
146+
self::assertEquals(123, $case->getCaseId());
147147
}
148148
}

Model/CaseServices/CreationServiceTest.php

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
*/
66
namespace Magento\Signifyd\Model\CaseServices;
77

8-
use Magento\Framework\Api\FilterBuilder;
98
use Magento\Framework\Api\SearchCriteriaBuilder;
109
use Magento\Framework\App\ObjectManager;
1110
use Magento\Sales\Api\Data\OrderInterface;
1211
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
1312
use Magento\Sales\Api\OrderRepositoryInterface;
1413
use Magento\Sales\Model\Order;
14+
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection;
1515
use Magento\Signifyd\Api\CaseRepositoryInterface;
1616
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
1717
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
@@ -98,16 +98,16 @@ public function testCreateForOrderWithEmptyResponse()
9898
$order = $this->getOrder();
9999
$exceptionMessage = 'Response is not valid JSON: Decoding failed: Syntax error';
100100

101-
$this->requestBuilder->expects(static::once())
101+
$this->requestBuilder->expects(self::once())
102102
->method('doRequest')
103103
->willThrowException(new ApiCallException($exceptionMessage));
104104

105-
$this->logger->expects(static::once())
105+
$this->logger->expects(self::once())
106106
->method('error')
107107
->with($exceptionMessage);
108108

109109
$result = $this->service->createForOrder($order->getEntityId());
110-
static::assertTrue($result);
110+
self::assertTrue($result);
111111
}
112112

113113
/**
@@ -124,16 +124,16 @@ public function testCreateForOrderWithBadResponse()
124124
];
125125
$exceptionMessage = 'Bad Request - The request could not be parsed. Response: ' . json_encode($responseData);
126126

127-
$this->requestBuilder->expects(static::once())
127+
$this->requestBuilder->expects(self::once())
128128
->method('doRequest')
129129
->willThrowException(new ApiCallException($exceptionMessage));
130130

131-
$this->logger->expects(static::once())
131+
$this->logger->expects(self::once())
132132
->method('error')
133133
->with($exceptionMessage);
134134

135135
$result = $this->service->createForOrder($order->getEntityId());
136-
static::assertTrue($result);
136+
self::assertTrue($result);
137137
}
138138

139139
/**
@@ -144,16 +144,16 @@ public function testCreateOrderWithEmptyInvestigationId()
144144
{
145145
$order = $this->getOrder();
146146

147-
$this->requestBuilder->expects(static::once())
147+
$this->requestBuilder->expects(self::once())
148148
->method('doRequest')
149149
->willReturn([]);
150150

151-
$this->logger->expects(static::once())
151+
$this->logger->expects(self::once())
152152
->method('error')
153153
->with('Expected field "investigationId" missed.');
154154

155155
$result = $this->service->createForOrder($order->getEntityId());
156-
static::assertTrue($result);
156+
self::assertTrue($result);
157157
}
158158

159159
/**
@@ -164,24 +164,24 @@ public function testCreateForOrder()
164164
{
165165
$order = $this->getOrder();
166166

167-
$this->requestBuilder->expects(static::once())
167+
$this->requestBuilder->expects(self::once())
168168
->method('doRequest')
169169
->willReturn(['investigationId' => 123123]);
170170

171-
$this->logger->expects(static::never())
171+
$this->logger->expects(self::never())
172172
->method('error');
173173

174174
$result = $this->service->createForOrder($order->getEntityId());
175-
static::assertTrue($result);
175+
self::assertTrue($result);
176176

177177
/** @var CaseRepositoryInterface $caseRepository */
178178
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
179179
$caseEntity = $caseRepository->getByCaseId(123123);
180180
$gridGuarantyStatus = $this->getOrderGridGuarantyStatus($caseEntity->getOrderId());
181181

182-
static::assertNotEmpty($caseEntity);
183-
static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
184-
static::assertEquals(
182+
self::assertNotEmpty($caseEntity);
183+
self::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
184+
self::assertEquals(
185185
$gridGuarantyStatus,
186186
$caseEntity->getGuaranteeDisposition(),
187187
'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
@@ -190,15 +190,15 @@ public function testCreateForOrder()
190190
/** @var OrderRepositoryInterface $orderRepository */
191191
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
192192
$order = $orderRepository->get($caseEntity->getOrderId());
193-
static::assertEquals(Order::STATE_HOLDED, $order->getState());
193+
self::assertEquals(Order::STATE_HOLDED, $order->getState());
194194

195195
$histories = $order->getStatusHistories();
196-
static::assertNotEmpty($histories);
196+
self::assertNotEmpty($histories);
197197

198198
/** @var OrderStatusHistoryInterface $orderHoldComment */
199199
$orderHoldComment = array_pop($histories);
200-
static::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
201-
static::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
200+
self::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
201+
self::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
202202
}
203203

204204
/**
@@ -209,17 +209,10 @@ public function testCreateForOrder()
209209
private function getOrder()
210210
{
211211
if ($this->order === null) {
212-
/** @var FilterBuilder $filterBuilder */
213-
$filterBuilder = $this->objectManager->get(FilterBuilder::class);
214-
$filters = [
215-
$filterBuilder->setField(OrderInterface::INCREMENT_ID)
216-
->setValue('100000001')
217-
->create()
218-
];
219212

220213
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
221214
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
222-
$searchCriteria = $searchCriteriaBuilder->addFilters($filters)
215+
$searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
223216
->create();
224217

225218
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
@@ -240,10 +233,8 @@ private function getOrder()
240233
*/
241234
private function getOrderGridGuarantyStatus($orderEntityId)
242235
{
243-
/** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
244-
$orderGridCollection = $this->objectManager->get(
245-
\Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
246-
);
236+
/** @var Collection $orderGridCollection */
237+
$orderGridCollection = $this->objectManager->get(Collection::class);
247238

248239
$items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
249240
->getItems();

0 commit comments

Comments
 (0)