Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved some tests to a new test case file
- Loading branch information
Showing
2 changed files
with
66 additions
and
27 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since 3.0.0 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
namespace Cake\Test\TestCase\ORM; | ||
|
||
use Cake\ORM\Association; | ||
use Cake\ORM\Table; | ||
use Cake\ORM\TableRegistry; | ||
use Cake\TestSuite\TestCase; | ||
|
||
/** | ||
* Tests the features related to proxying methods from the Association | ||
* class to the Table class | ||
* | ||
*/ | ||
class AssociationProxyTest extends TestCase { | ||
|
||
/** | ||
* Fixtures to be loaded | ||
* | ||
* @var array | ||
*/ | ||
public $fixtures = [ | ||
'core.article', 'core.author', 'core.comment' | ||
]; | ||
|
||
/** | ||
* Tests that it is possible to get associations as a property | ||
* | ||
* @return void | ||
*/ | ||
public function testAssociationAsProperty() { | ||
$articles = TableRegistry::get('articles'); | ||
$articles->hasMany('comments'); | ||
$articles->belongsTo('authors'); | ||
$this->assertTrue(isset($articles->authors)); | ||
$this->assertTrue(isset($articles->comments)); | ||
$this->assertFalse(isset($articles->posts)); | ||
$this->assertSame($articles->association('authors'), $articles->authors); | ||
$this->assertSame($articles->association('comments'), $articles->comments); | ||
} | ||
|
||
/** | ||
* Tests that getting a bad property throws exception | ||
* | ||
* @expectedException \RuntimeException | ||
* @expectedExceptionMessage Table "TestApp\Model\Table\ArticlesTable" is not associated with "posts" | ||
* @return void | ||
*/ | ||
public function testGetBadAssociation() { | ||
$articles = TableRegistry::get('articles'); | ||
$articles->posts; | ||
} | ||
|
||
} |
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