/** * Test if a proper table is created. * * @param string $file * @param array $shops * * @dataProvider createTableData() */ public function testCreateTable($file, array $shops = []) { $schemaManager = $this->getConnection()->getSchemaManager(); $tableManager = new TableManager($this->getConnection(), 'jobs_test', $shops); $this->importData('TableManagerTest/' . $file); $properType = $schemaManager->listTableDetails('jobs_test'); $schemaManager->dropTable('jobs_test'); $tableManager->createTable(); $createdType = $schemaManager->listTableDetails('jobs_test'); $this->compareTable($properType, $createdType); }
/** * Test for createTable() in case of multi shop (expected multiple `status` fields). */ public function testCreateTableMultiShop() { $connection = $this->getConnection(); /** @var AbstractSchemaManager|MockObject $schemaManager */ $schemaManager = $connection->getSchemaManager(); $schemaManager->expects($this->once())->method('createTable')->with($this->callback(function ($table) { /** @var Table $table */ $fieldNames = []; foreach ($table->getColumns() as $column) { $fieldNames[] = $column->getName(); } // Test if expected fields are set. $this->assertContains('status_alpha', $fieldNames); $this->assertContains('status_beta', $fieldNames); return true; })); $service = new TableManager($connection, 'test_table_name', ['alpha', 'beta']); $this->assertTrue($service->createTable()); }