ソースを参照

Adding explicit test for BTM strategy failure

Patrick Conroy 11 年 前
コミット
cedecc72d7
1 ファイル変更13 行追加7 行削除
  1. 13 7
      tests/TestCase/ORM/Association/BelongsToManyTest.php

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

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