Browse Source

Merge branch 'master' into 3.next

Mark Story 8 years ago
parent
commit
a675a9ccf6

+ 2 - 2
src/Database/Driver.php

@@ -18,7 +18,7 @@ use InvalidArgumentException;
 use PDO;
 
 /**
- * Represents a database diver containing all specificities for
+ * Represents a database driver containing all specificities for
  * a database engine including its SQL dialect
  */
 abstract class Driver
@@ -70,7 +70,7 @@ abstract class Driver
     /**
      * Establishes a connection to the database server
      *
-     * @return bool true con success
+     * @return bool true on success
      */
     abstract public function connect();
 

+ 6 - 0
src/Database/Query.php

@@ -1695,9 +1695,15 @@ class Query implements ExpressionInterface, IteratorAggregate
      *
      * @param string $name name of the clause to be returned
      * @return mixed
+     * @throws InvalidArgumentException When the named clause does not exist.
      */
     public function clause($name)
     {
+        if (!array_key_exists($name, $this->_parts)) {
+            $clauses = implode(', ', array_keys($this->_parts));
+            throw new InvalidArgumentException("The '$name' clause is not defined. Valid clauses are: $clauses");
+        }
+
         return $this->_parts[$name];
     }
 

+ 1 - 1
src/Http/ServerRequest.php

@@ -1510,7 +1510,7 @@ class ServerRequest implements ArrayAccess, ServerRequestInterface
      * $request->getData('Post.title');
      *
      * // With a default value.
-     * $request->getData('Post.not there', 'default value);
+     * $request->getData('Post.not there', 'default value');
      * ```
      *
      * When reading values you will get `null` for keys/values that do not exist.

+ 7 - 7
src/ORM/Behavior/TranslateBehavior.php

@@ -308,7 +308,7 @@ class TranslateBehavior extends Behavior implements PropertyMarshalInterface
         // entity persists.
         if ($noFields && $bundled && !$key) {
             foreach ($this->_config['fields'] as $field) {
-                $entity->dirty($field, true);
+                $entity->setDirty($field, true);
             }
 
             return;
@@ -347,10 +347,10 @@ class TranslateBehavior extends Behavior implements PropertyMarshalInterface
 
         $entity->set('_i18n', array_merge($bundled, array_values($modified + $new)));
         $entity->set('_locale', $locale, ['setter' => false]);
-        $entity->dirty('_locale', false);
+        $entity->setDirty('_locale', false);
 
         foreach ($fields as $field) {
-            $entity->dirty($field, false);
+            $entity->setDirty($field, false);
         }
     }
 
@@ -393,13 +393,13 @@ class TranslateBehavior extends Behavior implements PropertyMarshalInterface
                             $translations[$language] = $this->_table->newEntity();
                         }
                         $marshaller->merge($translations[$language], $fields, $options);
-                        if ((bool)$translations[$language]->errors()) {
-                            $errors[$language] = $translations[$language]->errors();
+                        if ((bool)$translations[$language]->getErrors()) {
+                            $errors[$language] = $translations[$language]->getErrors();
                         }
                     }
                     // Set errors into the root entity, so validation errors
                     // match the original form data position.
-                    $entity->errors($errors);
+                    $entity->setErrors($errors);
                 }
 
                 return $translations;
@@ -615,7 +615,7 @@ class TranslateBehavior extends Behavior implements PropertyMarshalInterface
 
         foreach ($translations as $lang => $translation) {
             foreach ($fields as $field) {
-                if (!$translation->dirty($field)) {
+                if (!$translation->isDirty($field)) {
                     continue;
                 }
                 $find[] = ['locale' => $lang, 'field' => $field, 'foreign_key' => $key];

+ 14 - 0
tests/TestCase/Database/QueryTest.php

@@ -4342,6 +4342,20 @@ class QueryTest extends TestCase
     }
 
     /**
+     * Test that reading an undefined clause does not emit an error.
+     *
+     * @expectedException \InvalidArgumentException
+     * @expectedExceptionMessage The 'nope' clause is not defined. Valid clauses are: delete, update
+     * @return void
+     */
+    public function testClauseUndefined()
+    {
+        $query = new Query($this->connection);
+        $this->assertEmpty($query->clause('where'));
+        $query->clause('nope');
+    }
+
+    /**
      * Assertion for comparing a table's contents with what is in it.
      *
      * @param string $table