Commit 5c3e4fa4 by Alexander Makarov

Adjusted unit tests, added description to docs

parent 39b0c454
...@@ -193,6 +193,15 @@ Customer::updateAllCounters(['age' => 1]); ...@@ -193,6 +193,15 @@ Customer::updateAllCounters(['age' => 1]);
> Info: The `save()` method will either perform an `INSERT` or `UPDATE` SQL statement, depending > Info: The `save()` method will either perform an `INSERT` or `UPDATE` SQL statement, depending
on whether the ActiveRecord being saved is new or not by checking `ActiveRecord::isNewRecord`. on whether the ActiveRecord being saved is new or not by checking `ActiveRecord::isNewRecord`.
In order to load default values from database schema you may call `loadDefaultValues()` method:
```php
$customer = new Customer();
$customer->loadDefaultValues();
$cusomer->name = 'Alexander';
$customer->save();
```
Data Input and Validation Data Input and Validation
------------------------- -------------------------
......
...@@ -491,6 +491,7 @@ class ActiveRecordTest extends DatabaseTestCase ...@@ -491,6 +491,7 @@ class ActiveRecordTest extends DatabaseTestCase
public function testDefaultValues() public function testDefaultValues()
{ {
$model = new Type(); $model = new Type();
$model->loadDefaultValues();
$this->assertEquals(1, $model->int_col2); $this->assertEquals(1, $model->int_col2);
$this->assertEquals('something', $model->char_col2); $this->assertEquals('something', $model->char_col2);
$this->assertEquals(1.23, $model->float_col2); $this->assertEquals(1.23, $model->float_col2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment