Skip to content

Commit

Permalink
Add test for method getVersionId
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Bouland committed May 9, 2017
1 parent 5542910 commit 18f6784
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/Model/Behavior/VersionBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,25 @@ public function testAssociations()
$this->assertInstanceOf('Cake\Orm\Association\HasMany', $bodyVersions);
$this->assertEquals('body_version', $bodyVersions->property());
}

/**
* @return void
*/
public function testGetVersionId()
{
// init test data
$table = TableRegistry::get('Articles', [
'entityClass' => 'Josegonzalez\Version\Test\TestCase\Model\Behavior\TestEntity',
]);
$table->addBehavior('Josegonzalez/Version.Version');
$article = $table->find('all')->where(['version_id' => 2])->first();
$article->title = 'First Article Version 3';
$table->save($article);

// action in controller receiving outdated data
$table->patchEntity($article, ['version_id' => 2]);

$this->assertEquals(2, $article->version_id);
$this->assertEquals(3, $table->getVersionId($article));
}
}

0 comments on commit 18f6784

Please sign in to comment.