-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
CollectionTest.php
77 lines (68 loc) · 2.59 KB
/
CollectionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Model\ResourceModel\Grid;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Customer grid collection tests.
*/
class CollectionTest extends \Magento\TestFramework\Indexer\TestCase
{
public static function setUpBeforeClass()
{
$db = Bootstrap::getInstance()->getBootstrap()
->getApplication()
->getDbInstance();
if (!$db->isDbDumpExists()) {
throw new \LogicException('DB dump does not exist.');
}
$db->restoreFromDbDump();
parent::setUpBeforeClass();
}
/**
* Test updated data for customer grid indexer during save/update customer data(including address data)
* in 'Update on Schedule' mode.
*
* Customer Grid Indexer can't work in 'Update on Schedule' mode. All data for indexer must be updated in realtime
* during save/update customer data(including address data).
*
* @magentoDataFixture Magento/Customer/_files/customer_grid_indexer_enabled_update_on_schedule.php
* @magentoDataFixture Magento/Customer/_files/customer_sample.php
* @magentoAppIsolation enabled
* @magentoDbIsolation disabled
*/
public function testGetItemByIdForUpdateOnSchedule()
{
$targetObject = Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\ResourceModel\Grid\Collection::class
);
$customerRepository = Bootstrap::getObjectManager()->create(
CustomerRepositoryInterface::class
);
/** Verify after first save */
/** @var CustomerInterface $newCustomer */
$newCustomer = $customerRepository->get('customer@example.com');
/** @var CustomerInterface $item */
$item = $targetObject->getItemById($newCustomer->getId());
$this->assertNotEmpty($item);
$this->assertSame($newCustomer->getEmail(), $item->getEmail());
$this->assertSame('test street test city Armed Forces Middle East 01001', $item->getBillingFull());
/** Verify after update */
$newCustomer->setEmail('customer_updated@example.com');
$customerRepository->save($newCustomer);
$targetObject->clear();
$item = $targetObject->getItemById($newCustomer->getId());
$this->assertSame($newCustomer->getEmail(), $item->getEmail());
}
/**
* teardown
*/
public function tearDown()
{
parent::tearDown();
}
}