Commit 4084f97a authored by jeroendedauw's avatar jeroendedauw

Add testGivenForeignKeyWithZeroLength_acceptForeignKeyThrowsException

parent d328488d
...@@ -50,12 +50,12 @@ class DropSchemaSqlCollector extends AbstractVisitor ...@@ -50,12 +50,12 @@ class DropSchemaSqlCollector extends AbstractVisitor
private $tables; private $tables;
/** /**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform * @var AbstractPlatform
*/ */
private $platform; private $platform;
/** /**
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform * @param AbstractPlatform $platform
*/ */
public function __construct(AbstractPlatform $platform) public function __construct(AbstractPlatform $platform)
{ {
......
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
namespace Doctrine\Tests\DBAL\Schema\Visitor; namespace Doctrine\Tests\DBAL\Schema\Visitor;
use \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
/**
* @covers Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector
*/
class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
{ {
public function testGetQueriesUsesAcceptedForeignKeys() public function testGetQueriesUsesAcceptedForeignKeys()
{ {
$tableOne = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table'); $tableOne = $this->getTableMock();
$tableTwo = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table'); $tableTwo = $this->getTableMock();
$keyConstraintOne = $this->getStubKeyConstraint('first'); $keyConstraintOne = $this->getStubKeyConstraint('first');
$keyConstraintTwo = $this->getStubKeyConstraint('second'); $keyConstraintTwo = $this->getStubKeyConstraint('second');
...@@ -37,6 +40,11 @@ class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase ...@@ -37,6 +40,11 @@ class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
$collector->getQueries(); $collector->getQueries();
} }
private function getTableMock()
{
return $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table');
}
private function getMockWithoutArguments($className) private function getMockWithoutArguments($className)
{ {
return $this->getMockBuilder($className)->disableOriginalConstructor()->getMock(); return $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
...@@ -50,6 +58,24 @@ class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase ...@@ -50,6 +58,24 @@ class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
->method('getName') ->method('getName')
->will($this->returnValue($name)); ->will($this->returnValue($name));
$constraint->expects($this->any())
->method('getForeignColumns')
->will($this->returnValue(array()));
$constraint->expects($this->any())
->method('getColumns')
->will($this->returnValue(array()));
return $constraint; return $constraint;
} }
public function testGivenForeignKeyWithZeroLength_acceptForeignKeyThrowsException()
{
$collector = new DropSchemaSqlCollector(
$this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform')
);
$this->setExpectedException( 'Doctrine\DBAL\Schema\SchemaException' );
$collector->acceptForeignKey($this->getTableMock(), $this->getStubKeyConstraint(''));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment