-
-
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 #14003 from SidRoberts/model-relation-isforeignkey
Model\Relation::isForeignKey() now returns false if the option is false
- Loading branch information
Showing
3 changed files
with
101 additions
and
4 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
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
namespace Phalcon\Test\Integration\Mvc\Model\Relation; | ||
|
||
use IntegrationTester; | ||
use Phalcon\Mvc\Model\Relation; | ||
|
||
/** | ||
* Class IsForeignKeyCest | ||
|
@@ -24,12 +25,101 @@ class IsForeignKeyCest | |
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2018-11-13 | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationIsForeignKey(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - isForeignKey()'); | ||
$I->skipTest('Need implementation'); | ||
|
||
|
||
|
||
$options = []; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertFalse( | ||
$relation->isForeignKey() | ||
); | ||
|
||
|
||
|
||
$options = [ | ||
'foreignKey' => false, | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertFalse( | ||
$relation->isForeignKey() | ||
); | ||
|
||
|
||
|
||
$options = [ | ||
'foreignKey' => [], | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertFalse( | ||
$relation->isForeignKey() | ||
); | ||
|
||
|
||
|
||
$options = [ | ||
'foreignKey' => true, | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertTrue( | ||
$relation->isForeignKey() | ||
); | ||
|
||
|
||
|
||
$options = [ | ||
'foreignKey' => [ | ||
'message' => 'The part_id does not exist on the Parts model', | ||
], | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertTrue( | ||
$relation->isForeignKey() | ||
); | ||
} | ||
} |