Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ResourceTest.php
Go to the documentation of this file.
1 <?php
9 
10 class ResourceTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $_model;
16 
17  protected function setUp()
18  {
20  ->create(\Magento\Framework\App\ResourceConnection::class);
21  }
22 
23  public function testGetTableName()
24  {
25  $tablePrefix = 'prefix_';
26  $tableSuffix = 'suffix';
27  $tableNameOrig = 'store_website';
28 
30  \Magento\Framework\App\ResourceConnection::class,
31  ['tablePrefix' => 'prefix_']
32  );
33 
34  $tableName = $this->_model->getTableName([$tableNameOrig, $tableSuffix]);
35  $this->assertContains($tablePrefix, $tableName);
36  $this->assertContains($tableSuffix, $tableName);
37  $this->assertContains($tableNameOrig, $tableName);
38  }
39 
44  public function testProfilerInit()
45  {
47 
49  $connection = $objectManager->create(
50  \Magento\TestFramework\Db\Adapter\Mysql::class,
51  [
52  'config' => [
53  'profiler' => [
54  'class' => \Magento\Framework\Model\ResourceModel\Db\Profiler::class,
55  'enabled' => 'true',
56  ],
57  'username' => 'username',
58  'password' => 'password',
59  'host' => 'host',
60  'type' => 'type',
61  'dbname' => 'dbname',
62  ]
63  ]
64  );
65 
67  $profiler = $connection->getProfiler();
68 
69  $this->assertInstanceOf(\Magento\Framework\Model\ResourceModel\Db\Profiler::class, $profiler);
70  $this->assertTrue($profiler->getEnabled());
71  }
72 }
$tableName
Definition: trigger.php:13
$objectManager
Definition: bootstrap.php:17
$connection
Definition: bulk.php:13