Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #586 from JeroenDeDauw/DropSchemaSqlCollector
Change weird way of adding an entry to SplObjectStorage
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Schema\Visitor; | ||
|
||
use \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; | ||
|
||
class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testGetQueriesUsesAcceptedForeignKeys() | ||
{ | ||
$tableOne = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table'); | ||
$tableTwo = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table'); | ||
|
||
$keyConstraintOne = $this->getStubKeyConstraint('first'); | ||
$keyConstraintTwo = $this->getStubKeyConstraint('second'); | ||
|
||
$platform = $this->getMockBuilder('Doctrine\DBAL\Platforms\AbstractPlatform') | ||
->setMethods(array('getDropForeignKeySQL')) | ||
->getMockForAbstractClass(); | ||
|
||
$collector = new DropSchemaSqlCollector($platform); | ||
|
||
$platform->expects($this->exactly(2)) | ||
->method('getDropForeignKeySQL'); | ||
|
||
$platform->expects($this->at(0)) | ||
->method('getDropForeignKeySQL') | ||
->with($keyConstraintOne, $tableOne); | ||
|
||
$platform->expects($this->at(1)) | ||
->method('getDropForeignKeySQL') | ||
->with($keyConstraintTwo, $tableTwo); | ||
|
||
$collector->acceptForeignKey($tableOne, $keyConstraintOne); | ||
$collector->acceptForeignKey($tableTwo, $keyConstraintTwo); | ||
|
||
$collector->getQueries(); | ||
} | ||
|
||
private function getMockWithoutArguments($className) | ||
{ | ||
return $this->getMockBuilder($className)->disableOriginalConstructor()->getMock(); | ||
} | ||
|
||
private function getStubKeyConstraint($name) | ||
{ | ||
$constraint = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\ForeignKeyConstraint'); | ||
|
||
$constraint->expects($this->any()) | ||
->method('getName') | ||
->will($this->returnValue($name)); | ||
|
||
return $constraint; | ||
} | ||
} |