Ejemplo n.º 1
0
 /**
  * Test if table is updated properly.
  */
 public function testUpdateTable()
 {
     $schemaManager = $this->getConnection()->getSchemaManager();
     $tableManager = new TableManager($this->getConnection(), 'jobs_test', ['shop1', 'shop2', 'shop3']);
     $this->importData('TableManagerTest/tableOutdated.sql');
     $tableManager->updateTable();
     $updatedTable = $schemaManager->listTableDetails('jobs_test');
     $schemaManager->dropTable('jobs_test');
     $this->importData('TableManagerTest/tableMultiple.sql');
     $this->compareTable($schemaManager->listTableDetails('jobs_test'), $updatedTable);
 }
Ejemplo n.º 2
0
 /**
  * Test for updateTable() with a custom connection provided.
  */
 public function testUpdateTableCustomConnection()
 {
     /** @var Connection|MockObject $defaultConnection */
     $defaultConnection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $defaultConnection->expects($this->never())->method('getSchemaManager');
     $schemaManager = $this->getMockBuilder('Doctrine\\DBAL\\Schema\\AbstractSchemaManager')->disableOriginalConstructor()->setMethods(get_class_methods('Doctrine\\DBAL\\Schema\\AbstractSchemaManager'))->getMockForAbstractClass();
     $schemaManager->expects($this->once())->method('tablesExist')->willReturn(true);
     $schemaManager->expects($this->once())->method('listTableDetails')->willReturn(new Table('any_table'));
     $schemaManager->expects($this->once())->method('alterTable');
     /** @var Connection|MockObject $customConnection */
     $customConnection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $customConnection->expects($this->once())->method('getSchemaManager')->willReturn($schemaManager);
     $manager = new TableManager($defaultConnection);
     $this->assertTrue($manager->updateTable($customConnection));
 }