Skip to content
Permalink
Browse files

Add tests for belongsTo and null property values.

  • Loading branch information...
markstory committed Jul 11, 2014
1 parent 2c36545 commit 9dfe876de0fed2c35019b52f1a8f174878d3fa37
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/TestCase/ORM/Association/BelongsToTest.php
@@ -29,6 +29,20 @@
*/
class BelongsToTest extends \Cake\TestSuite\TestCase {
/**
* Fixtures to use.
*
* @var array
*/
public $fixtures = ['core.article', 'core.comment'];
/**
* Don't autoload fixtures as most tests uses mocks.
*
* @var bool
*/
public $autoFixture = false;
/**
* Set up
*
@@ -432,4 +446,22 @@ public function testAttachToBeforeFindExtraOptions() {
}]);
}
/**
* Test that eagerLoader leaves empty associations unpopulated.
*
* @return void
*/
public function testEagerLoaderLeavesEmptyAssocation() {
$this->loadFixtures('Article', 'Comment');
$comments = TableRegistry::get('Comments');
$comments->belongsTo('Articles');
// Clear the articles table so we can trigger an empty belongsTo
$articles = TableRegistry::get('Articles');
$articles->deleteAll([]);
$comment = $comments->get(1, ['contain' => ['Articles']]);
$this->assertNull($comment->article);
}
}

0 comments on commit 9dfe876

Please sign in to comment.
You can’t perform that action at this time.