Browse Source

Updating providers for association strategy tests

Patrick Conroy 11 years ago
parent
commit
c95ba7945f
1 changed files with 35 additions and 23 deletions
  1. 35 23
      tests/TestCase/ORM/CompositeKeysTest.php

+ 35 - 23
tests/TestCase/ORM/CompositeKeysTest.php

@@ -65,11 +65,41 @@ class CompositeKeyTest extends TestCase
     }
 
     /**
+     * Data provider for the two types of strategies HasOne implements
+     *
+     * @return void
+     */
+    public function strategiesProviderHasOne()
+    {
+        return [['join'], ['select']];
+    }
+
+    /**
      * Data provider for the two types of strategies HasMany implements
      *
      * @return void
      */
-    public function strategiesProvider()
+    public function strategiesProviderHasMany()
+    {
+        return [['subquery'], ['select']];
+    }
+
+    /**
+     * Data provider for the two types of strategies BelongsTo implements
+     *
+     * @return void
+     */
+    public function strategiesProviderBelongsTo()
+    {
+        return [['join'], ['select']];
+    }
+
+    /**
+     * Data provider for the two types of strategies BelongsToMany implements
+     *
+     * @return void
+     */
+    public function strategiesProviderBelongsToMany()
     {
         return [['subquery'], ['select']];
     }
@@ -78,7 +108,7 @@ class CompositeKeyTest extends TestCase
      * Tests that HasMany associations are correctly eager loaded and results
      * correctly nested when multiple foreignKeys are used
      *
-     * @dataProvider strategiesProvider
+     * @dataProvider strategiesProviderHasMany
      * @return void
      */
     public function testHasManyEager($strategy)
@@ -154,7 +184,7 @@ class CompositeKeyTest extends TestCase
      * Tests that BelongsToMany associations are correctly eager loaded when multiple
      * foreignKeys are used
      *
-     * @dataProvider strategiesProvider
+     * @dataProvider strategiesProviderBelongsToMany
      * @return void
      */
     public function testBelongsToManyEager($strategy)
@@ -239,27 +269,13 @@ class CompositeKeyTest extends TestCase
     }
 
     /**
-     * Provides strategies for associations that can be joined
-     *
-     * @return void
-     */
-    public function internalStategiesProvider()
-    {
-        return [['join'], ['select'], ['subquery']];
-    }
-
-    /**
      * Tests loding belongsTo with composite keys
      *
-     * @dataProvider internalStategiesProvider
+     * @dataProvider strategiesProviderBelongsTo
      * @return void
      */
     public function testBelongsToEager($strategy)
     {
-        $assoc = new BelongsTo('Test');
-        if (!$assoc->validStrategy($strategy)) {
-            return;
-        }
         $table = TableRegistry::get('SiteArticles');
         $table->belongsTo('SiteAuthors', [
             'propertyName' => 'author',
@@ -304,15 +320,11 @@ class CompositeKeyTest extends TestCase
     /**
      * Tests loding hasOne with composite keys
      *
-     * @dataProvider internalStategiesProvider
+     * @dataProvider strategiesProviderHasOne
      * @return void
      */
     public function testHasOneEager($strategy)
     {
-        $assoc = new HasOne('Test');
-        if (!$assoc->validStrategy($strategy)) {
-            return;
-        }
         $table = TableRegistry::get('SiteAuthors');
         $table->hasOne('SiteArticles', [
             'propertyName' => 'first_article',