Browse Source

Adding some doc blocks

Jose Lorenzo Rodriguez 10 years ago
parent
commit
60536a07c1
3 changed files with 28 additions and 0 deletions
  1. 10 0
      src/ORM/Association.php
  2. 3 0
      src/ORM/Association/BelongsToMany.php
  3. 15 0
      tests/TestCase/ORM/QueryTest.php

+ 10 - 0
src/ORM/Association.php

@@ -471,6 +471,8 @@ abstract class Association
      *   properties to be followed from the passed query main entity to this
      *   association
      * - joinType: The SQL join type to use in the query.
+     * - negateMatch: Will append a condition to the passed query for excluding matches.
+     *   with this association.
      *
      * @param Query $query the query to be altered to include the target table data
      * @param array $options Any extra options or overrides to be taken in account
@@ -526,6 +528,14 @@ abstract class Association
         $this->_appendNotMatching($query, $options);
     }
 
+    /**
+     * Conditionally adds a condition to the passed Query that will make it find
+     * records where there is no match with this association.
+     *
+     * @param \Cake\Database\Query $query The query to modify
+     * @param array $options Options array containing the `negateMatch` key.
+     * @return void
+     */
     protected function _appendNotMatching($query, $options)
     {
         $target = $this->_targetTable;

+ 3 - 0
src/ORM/Association/BelongsToMany.php

@@ -262,6 +262,9 @@ class BelongsToMany extends Association
         $query->eagerLoader()->addToJoinsMap($junction->alias(), $assoc, true);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     protected function _appendNotMatching($query, $options)
     {
         $target = $junction = $this->junction();

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

@@ -2845,6 +2845,11 @@ class QueryTest extends TestCase
         $this->assertEquals($expected, $results);
     }
 
+    /**
+     * Tests notMatching() with and without conditions
+     *
+     * @return void
+     */
     public function testNotMatching()
     {
         $table = TableRegistry::get('authors');
@@ -2875,6 +2880,11 @@ class QueryTest extends TestCase
         $this->assertEquals($expected, $results);
     }
 
+    /**
+     * Tests notMatching() with a belongsToMany association
+     *
+     * @return void
+     */
     public function testNotMatchingBelongsToMany()
     {
         $table = TableRegistry::get('articles');
@@ -2906,6 +2916,11 @@ class QueryTest extends TestCase
         $this->assertEquals($expected, $results);
     }
 
+    /**
+     * Tests notMatching() with a deeply nested belongsToMany association.
+     *
+     * @return void
+     */
     public function testNotMatchingDeep()
     {
         $table = TableRegistry::get('authors');