Advertisement
Guest User

This does not work

a guest
May 1st, 2014
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Doctrine\Tests\DBAL\Schema\Visitor;
  4.  
  5. use \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
  6.  
  7. class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
  8. {
  9.     public function testGetQueriesUsesAcceptedForeignKeys()
  10.     {
  11.         $tableOne = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table');
  12.         $tableTwo = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table');
  13.  
  14.         $keyConstraintOne = $this->getStubKeyConstraint('first');
  15.         $keyConstraintTwo = $this->getStubKeyConstraint('second');
  16.  
  17.         $platform = $this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform');
  18.  
  19.         $collector = new DropSchemaSqlCollector($platform);
  20.  
  21.         $platform->expects($this->exactly(2))
  22.             ->method('getDropForeignKeySQL');
  23.  
  24.         $platform->expects($this->at(0))
  25.             ->method('getDropForeignKeySQL')
  26.             ->with($keyConstraintOne, $tableOne);
  27.  
  28.         $platform->expects($this->at(1))
  29.             ->method('getDropForeignKeySQL')
  30.             ->with($keyConstraintTwo, $tableTwo);
  31.  
  32.         $collector->acceptForeignKey($tableOne, $keyConstraintOne);
  33.         $collector->acceptForeignKey($tableTwo, $keyConstraintTwo);
  34.  
  35.         $collector->getQueries();
  36.     }
  37.  
  38.     private function getMockWithoutArguments($className)
  39.     {
  40.         return $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
  41.     }
  42.  
  43.     private function getStubKeyConstraint($name)
  44.     {
  45.         $constraint = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\ForeignKeyConstraint');
  46.  
  47.         $constraint->expects($this->any())
  48.             ->method('getName')
  49.             ->will($this->returnValue($name));
  50.  
  51.         return $constraint;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement