Browse Source

Fix tests for SqlServer

Yves P 10 years ago
parent
commit
0aeb8625fc

+ 1 - 0
src/TestSuite/Fixture/TestFixture.php

@@ -346,6 +346,7 @@ class TestFixture implements FixtureInterface
                 $db->execute($stmt)->closeCursor();
             }
         } catch (\Exception $e) {
+            debug($e);
             return false;
         }
 

+ 2 - 2
tests/Fixture/OrdersFixture.php

@@ -49,8 +49,8 @@ class OrdersFixture extends TestFixture
             ],
             'product_id_fk' => [
                 'type' => 'foreign',
-                'columns' => ['product_id', 'product_category'],
-                'references' => ['products', ['id', 'category']],
+                'columns' => ['product_category', 'product_id'],
+                'references' => ['products', ['category', 'id']],
                 'update' => 'cascade',
                 'delete' => 'cascade',
             ]

+ 1 - 1
tests/Fixture/ProductsFixture.php

@@ -37,7 +37,7 @@ class ProductsFixture extends TestFixture
         'category' => ['type' => 'integer', 'null' => false],
         'name' => ['type' => 'string', 'null' => false],
         'price' => ['type' => 'integer'],
-        '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'category']]]
+        '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['category', 'id']]]
     ];
 
     /**

+ 5 - 5
tests/TestCase/Database/Schema/TableTest.php

@@ -510,12 +510,12 @@ class TableTest extends TestCase
         $expected = [
             'type' => 'foreign',
             'columns' => [
-                'product_id',
-                'product_category'
+                'product_category',
+                'product_id'
             ],
             'references' => [
                 'products',
-                ['id', 'category']
+                ['category', 'id']
             ],
             'update' => 'cascade',
             'delete' => 'cascade',
@@ -524,8 +524,8 @@ class TableTest extends TestCase
 
         $this->assertEquals($expected, $compositeConstraint);
 
-        $expectedSubstring = 'CONSTRAINT <product_id_fk> FOREIGN KEY \(<product_id>, <product_category>\)' .
-            ' REFERENCES <products> \(<id>, <category>\)';
+        $expectedSubstring = 'CONSTRAINT <product_id_fk> FOREIGN KEY \(<product_category>, <product_id>\)' .
+            ' REFERENCES <products> \(<category>, <id>\)';
 
         $this->assertQuotedQuery($expectedSubstring, $table->schema()->createSql(ConnectionManager::get('test'))[0]);
     }