Browse Source

Cleaning up tests

Patrick Conroy 11 years ago
parent
commit
24df08da15

+ 13 - 7
tests/TestCase/ORM/Association/HasManyTest.php

@@ -120,13 +120,19 @@ class HasManyTest extends TestCase
         $this->assertFalse($assoc->requiresKeys());
         $assoc->strategy(HasMany::STRATEGY_SELECT);
         $this->assertTrue($assoc->requiresKeys());
-        $errorUsingJoin = false;
-        try {
-            $assoc->strategy(HasMany::STRATEGY_JOIN);
-        } catch (\InvalidArgumentException $e) {
-            $errorUsingJoin = true;
-        }
-        $this->assertTrue($errorUsingJoin);
+    }
+
+    /**
+     * Tests that HasMany can't use the join strategy
+     *
+     * @expectedException \InvalidArgumentException
+     * @expectedExceptionMessage Invalid strategy "join" was provided
+     * @return void
+     */
+    public function testStrategyFailure()
+    {
+        $assoc = new HasMany('Test');
+        $assoc->strategy(HasMany::STRATEGY_JOIN);
     }
 
     /**

+ 3 - 1
tests/TestCase/ORM/QueryRegressionTest.php

@@ -780,7 +780,9 @@ class QueryRegressionTest extends TestCase
     public function testHasManyEagerLoadingUniqueKey()
     {
         $table = TableRegistry::get('ArticlesTags');
-        $table->belongsTo('Articles');
+        $table->belongsTo('Articles', [
+            'strategy' => 'select'
+        ]);
 
         $result = $table->find()
             ->contain(['Articles' => function ($q) {

+ 0 - 2
tests/TestCase/ORM/QueryTest.php

@@ -19,8 +19,6 @@ use Cake\Database\Expression\OrderByExpression;
 use Cake\Database\Expression\QueryExpression;
 use Cake\Database\TypeMap;
 use Cake\Datasource\ConnectionManager;
-use Cake\ORM\Association\BelongsTo;
-use Cake\ORM\Association\HasOne;
 use Cake\ORM\Query;
 use Cake\ORM\ResultSet;
 use Cake\ORM\Table;