-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12767 from Jurigag/3.1.x-12766
Fixes #12766
- Loading branch information
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Phalcon\Test\Models\DynamicUpdate; | ||
|
||
use Phalcon\Mvc\Model; | ||
use Phalcon\Test\Models\RobotsParts; | ||
|
||
/** | ||
* \Phalcon\Test\Models\DynamicUpdate\Robots | ||
* | ||
* @copyright 2011-2017 Phalcon Team | ||
* @link https://phalconphp.com | ||
* @author Andres Gutierrez <andres@phalconphp.com> | ||
* @author Serghei Iakovlev <serghei@phalconphp.com> | ||
* @package Phalcon\Test\Models\DynamicUpdate | ||
* | ||
* @property int $id | ||
* @property string $name | ||
* @property string $type | ||
* @property int $year | ||
* @property string $datetime | ||
* @property string $deleted | ||
* @property string $text | ||
* | ||
* @method static Robots findFirst($parameters = null) | ||
* @method static Robots[] find($parameters = null) | ||
* | ||
* The contents of this file are subject to the New BSD License that is | ||
* bundled with this package in the file docs/LICENSE.txt | ||
* | ||
* If you did not receive a copy of the license and are unable to obtain it | ||
* through the world-wide-web, please send an email to license@phalconphp.com | ||
* so that we can send you a copy immediately. | ||
*/ | ||
class Robots extends Model | ||
{ | ||
public $year; | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('id', RobotsParts::class, 'robots_id'); | ||
|
||
$this->useDynamicUpdate(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Phalcon\Test\Unit\Mvc\Model; | ||
|
||
use Phalcon\Test\Models\DynamicUpdate\Robots; | ||
use Phalcon\Test\Module\UnitTest; | ||
|
||
/** | ||
* \Phalcon\Test\Unit\Mvc\Model\DynamicUpdateTest | ||
* Tests the Phalcon\Mvc\Model component | ||
* | ||
* @copyright (c) 2011-2017 Phalcon Team | ||
* @link https://phalconphp.com | ||
* @author Andres Gutierrez <andres@phalconphp.com> | ||
* @author Serghei Iakovlev <serghei@phalconphp.com> | ||
* @author Wojciech Ślawski <jurigag@gmail.com> | ||
* @package Phalcon\Test\Unit\Mvc\Model | ||
* | ||
* The contents of this file are subject to the New BSD License that is | ||
* bundled with this package in the file docs/LICENSE.txt | ||
* | ||
* If you did not receive a copy of the license and are unable to obtain it | ||
* through the world-wide-web, please send an email to license@phalconphp.com | ||
* so that we can send you a copy immediately. | ||
*/ | ||
class DynamicUpdateTest extends UnitTest | ||
{ | ||
/** | ||
* Tests dynamic update create then update | ||
* | ||
* @author Wojciech Ślawski <jurigag@gmail.com> | ||
* @issue 12766 | ||
* @since 2017-04-04 | ||
*/ | ||
public function testIssue12766() | ||
{ | ||
$robots = new Robots(); | ||
$robots->name = 'Test'; | ||
$robots->type = 'mechanical'; | ||
$robots->datetime = (new \DateTime())->format('Y-m-d'); | ||
$robots->text = 'text'; | ||
|
||
$robots->create(); | ||
|
||
$robots->year = 2017; | ||
$robots->update(); | ||
} | ||
} |