Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShardingTest.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class ShardingTest extends \PHPUnit\Framework\TestCase
13 {
15  private $model;
16 
18  private $objectManagerHelper;
19 
21  private $deploymentConfigMock;
22 
23  protected function setUp()
24  {
25  $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
26  ->disableOriginalConstructor()
27  ->getMock();
28 
29  $this->objectManagerHelper = new ObjectManagerHelper($this);
30  $this->model = $this->objectManagerHelper->getObject(
31  \Magento\Framework\Setup\Declaration\Schema\Sharding::class,
32  [
33  'deploymentConfig' => $this->deploymentConfigMock,
34  'resources' => ['default', 'checkout', 'sales']
35  ]
36  );
37  }
38 
39  public function testCanUseResource()
40  {
41  $this->deploymentConfigMock->expects(self::once())
42  ->method('get')
43  ->with('db/connection')
44  ->willReturn(['default']);
45  self::assertFalse($this->model->canUseResource('checkout'));
46  }
47 
48  public function testGetResources()
49  {
50  $this->deploymentConfigMock->expects(self::exactly(3))
51  ->method('get')
52  ->with('db/connection')
53  ->willReturn(['default' => 1, 'sales' => 2, 'index' => 3]);
54  self::assertEquals(['default', 'sales'], $this->model->getResources());
55  }
56 }