Advertisement
Guest User

This works

a guest
May 1st, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.85 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Doctrine\Tests\DBAL\Schema\Visitor;
  4.  
  5. use Doctrine\DBAL\Platforms\AbstractPlatform;
  6. use \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
  7.  
  8. class DropSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
  9. {
  10.     public function testGetQueriesUsesAcceptedForeignKeys()
  11.     {
  12.         $tableOne = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table');
  13.         $tableTwo = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table');
  14.  
  15.         $keyConstraintOne = $this->getStubKeyConstraint('first');
  16.         $keyConstraintTwo = $this->getStubKeyConstraint('second');
  17.  
  18.         $platform = $this->getMock('Doctrine\Tests\DBAL\Schema\Visitor\PlatformStub');
  19.  
  20.         $collector = new DropSchemaSqlCollector($platform);
  21.  
  22.         $platform->expects($this->exactly(2))
  23.             ->method('getDropForeignKeySQL');
  24.  
  25.         $platform->expects($this->at(0))
  26.             ->method('getDropForeignKeySQL')
  27.             ->with($keyConstraintOne, $tableOne);
  28.  
  29.         $platform->expects($this->at(1))
  30.             ->method('getDropForeignKeySQL')
  31.             ->with($keyConstraintTwo, $tableTwo);
  32.  
  33.         $collector->acceptForeignKey($tableOne, $keyConstraintOne);
  34.         $collector->acceptForeignKey($tableTwo, $keyConstraintTwo);
  35.  
  36.         $collector->getQueries();
  37.     }
  38.  
  39.     private function getMockWithoutArguments($className)
  40.     {
  41.         return $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
  42.     }
  43.  
  44.     private function getStubKeyConstraint($name)
  45.     {
  46.         $constraint = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\ForeignKeyConstraint');
  47.  
  48.         $constraint->expects($this->any())
  49.             ->method('getName')
  50.             ->will($this->returnValue($name));
  51.  
  52.         return $constraint;
  53.     }
  54. }
  55.  
  56. class PlatformStub extends AbstractPlatform {
  57.  
  58.     /**
  59.      * Returns the SQL snippet that declares a boolean column.
  60.      *
  61.      * @param array $columnDef
  62.      *
  63.      * @return string
  64.      */
  65.     public function getBooleanTypeDeclarationSQL( array $columnDef ) {
  66.         // TODO: Implement getBooleanTypeDeclarationSQL() method.
  67.     }
  68.  
  69.     /**
  70.      * Returns the SQL snippet that declares a 4 byte integer column.
  71.      *
  72.      * @param array $columnDef
  73.      *
  74.      * @return string
  75.      */
  76.     public function getIntegerTypeDeclarationSQL( array $columnDef ) {
  77.         // TODO: Implement getIntegerTypeDeclarationSQL() method.
  78.     }
  79.  
  80.     /**
  81.      * Returns the SQL snippet that declares an 8 byte integer column.
  82.      *
  83.      * @param array $columnDef
  84.      *
  85.      * @return string
  86.      */
  87.     public function getBigIntTypeDeclarationSQL( array $columnDef ) {
  88.         // TODO: Implement getBigIntTypeDeclarationSQL() method.
  89.     }
  90.  
  91.     /**
  92.      * Returns the SQL snippet that declares a 2 byte integer column.
  93.      *
  94.      * @param array $columnDef
  95.      *
  96.      * @return string
  97.      */
  98.     public function getSmallIntTypeDeclarationSQL( array $columnDef ) {
  99.         // TODO: Implement getSmallIntTypeDeclarationSQL() method.
  100.     }
  101.  
  102.     /**
  103.      * Returns the SQL snippet that declares common properties of an integer column.
  104.      *
  105.      * @param array $columnDef
  106.      *
  107.      * @return string
  108.      */
  109.     protected function _getCommonIntegerTypeDeclarationSQL( array $columnDef ) {
  110.         // TODO: Implement _getCommonIntegerTypeDeclarationSQL() method.
  111.     }
  112.  
  113.     /**
  114.      * Lazy load Doctrine Type Mappings.
  115.      *
  116.      * @return void
  117.      */
  118.     protected function initializeDoctrineTypeMappings() {
  119.         // TODO: Implement initializeDoctrineTypeMappings() method.
  120.     }
  121.  
  122.     /**
  123.      * Returns the SQL snippet used to declare a CLOB column type.
  124.      *
  125.      * @param array $field
  126.      *
  127.      * @return string
  128.      */
  129.     public function getClobTypeDeclarationSQL( array $field ) {
  130.         // TODO: Implement getClobTypeDeclarationSQL() method.
  131.     }
  132.  
  133.     /**
  134.      * Returns the SQL Snippet used to declare a BLOB column type.
  135.      *
  136.      * @param array $field
  137.      *
  138.      * @return string
  139.      */
  140.     public function getBlobTypeDeclarationSQL( array $field ) {
  141.         // TODO: Implement getBlobTypeDeclarationSQL() method.
  142.     }
  143.  
  144.     /**
  145.      * Gets the name of the platform.
  146.      *
  147.      * @return string
  148.      */
  149.     public function getName() {
  150.         // TODO: Implement getName() method.
  151.     }
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement