Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T14466 model changedfields #14468

Merged
merged 4 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[#14466] - Changed the exception text; Added tests
  • Loading branch information
niden committed Oct 14, 2019
commit e85b78af8d6aa86f738bbca4fb9045d1869f0b98
6 changes: 3 additions & 3 deletions phalcon/Mvc/Model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,

if unlikely typeof snapshot != "array" {
throw new Exception(
"The record doesn't have a valid data snapshot"
"The 'keepSnapshots' option must be enabled to track changes"
);
}

Expand Down Expand Up @@ -1855,13 +1855,13 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface,

if unlikely !globals_get("orm.update_snapshot_on_save") {
throw new Exception(
"Update snapshot on save must be enabled for this method to work properly"
"The 'updateSnapshotOnSave' option must be enabled for this method to work properly"
);
}

if unlikely typeof snapshot != "array" {
throw new Exception(
"The record doesn't have a valid data snapshot"
"The 'keepSnapshots' option must be enabled to track changes"
);
}

Expand Down
23 changes: 19 additions & 4 deletions tests/integration/Mvc/Model/GetChangedFieldsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,36 @@
namespace Phalcon\Test\Integration\Mvc\Model;

use IntegrationTester;
use Phalcon\Mvc\Model\Exception;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Models\Robots;

/**
* Class GetChangedFieldsCest
*/
class GetChangedFieldsCest
{
use DiTrait;

/**
* Tests Phalcon\Mvc\Model :: getChangedFields()
* Tests Phalcon\Mvc\Model :: getChangedFields() - keepSnapshots
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
*/
public function mvcModelGetChangedFields(IntegrationTester $I)
public function mvcModelGetChangedFieldsKeepSnapshots(IntegrationTester $I)
{
$I->wantToTest('Mvc\Model - getChangedFields()');
$I->skipTest('Need implementation');
$I->wantToTest('Mvc\Model - getChangedFields() - keepSnapshots');
$this->setNewFactoryDefault();
$this->setDiMysql();
$I->expectThrowable(
new Exception(
"The 'keepSnapshots' option must be enabled to track changes"
),
function () {
$robot = Robots::findFirst();
$fields = $robot->getChangedFields();
}
);
}
}
24 changes: 20 additions & 4 deletions tests/integration/Mvc/Model/GetUpdatedFieldsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,37 @@
namespace Phalcon\Test\Integration\Mvc\Model;

use IntegrationTester;
use Phalcon\Mvc\Model\Exception;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Models\Robots;

/**
* Class GetUpdatedFieldsCest
*/
class GetUpdatedFieldsCest
{
use DiTrait;

/**
* Tests Phalcon\Mvc\Model :: getUpdatedFields()
* Tests Phalcon\Mvc\Model :: getUpdatedFields() - keepSnapshots
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
*/
public function mvcModelGetUpdatedFields(IntegrationTester $I)
public function mvcModelGetUpdatedFieldsKeepSnapshots(IntegrationTester $I)
{
$I->wantToTest('Mvc\Model - getUpdatedFields()');
$I->skipTest('Need implementation');
$I->wantToTest('Mvc\Model - getUpdatedFields() - keepSnapshots');
$this->setNewFactoryDefault();
$this->setDiMysql();
$I->expectThrowable(
new Exception(
"The 'keepSnapshots' option must be enabled to track changes"
),
function () {
$robot = Robots::findFirst();
$fields = $robot ->getUpdatedFields();
}
);

}
}