|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Quote; |
| 9 | + |
| 10 | +use Magento\Framework\App\ObjectManager; |
| 11 | +use Magento\Framework\App\ResourceConnection; |
| 12 | +use Magento\Framework\DB\Adapter\AdapterInterface; |
| 13 | +use Monolog\Test\TestCase; |
| 14 | + |
| 15 | +class DbSchemaTest extends TestCase |
| 16 | +{ |
| 17 | + /** |
| 18 | + * @param string $tableName |
| 19 | + * @param string $indexName |
| 20 | + * @param array $columns |
| 21 | + * @param string $indexType |
| 22 | + * @return void |
| 23 | + * @dataProvider indexDataProvider |
| 24 | + */ |
| 25 | + public function testIndex( |
| 26 | + string $tableName, |
| 27 | + string $indexName, |
| 28 | + array $columns, |
| 29 | + string $indexType = AdapterInterface::INDEX_TYPE_INDEX, |
| 30 | + ): void { |
| 31 | + $connection = ObjectManager::getInstance()->get(ResourceConnection::class)->getConnection(); |
| 32 | + $indexes = $connection->getIndexList($tableName); |
| 33 | + $this->assertArrayHasKey($indexName, $indexes); |
| 34 | + $this->assertSame($columns, $indexes[$indexName]['COLUMNS_LIST']); |
| 35 | + $this->assertSame($indexType, $indexes[$indexName]['INDEX_TYPE']); |
| 36 | + } |
| 37 | + |
| 38 | + public function indexDataProvider(): array |
| 39 | + { |
| 40 | + return [ |
| 41 | + [ |
| 42 | + 'quote', |
| 43 | + 'QUOTE_STORE_ID_UPDATED_AT', |
| 44 | + ['store_id', 'updated_at'] |
| 45 | + ] |
| 46 | + ]; |
| 47 | + } |
| 48 | +} |
0 commit comments