-
-
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.
The property 'options' is always an array in Model Relations. (#13989)
* The property 'options' is always an array in Model Relations. * Added tests for Model Relation.
- Loading branch information
1 parent
2ce04de
commit 357293f
Showing
9 changed files
with
231 additions
and
47 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
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 GetFieldsCest | ||
|
@@ -24,12 +25,62 @@ class GetFieldsCest | |
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2018-11-13 | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationGetFields(IntegrationTester $I) | ||
public function mvcModelRelationGetFieldsString(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - getFields()'); | ||
$I->skipTest('Need implementation'); | ||
$I->wantToTest('Mvc\Model\Relation - getFields() - string'); | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
[ | ||
'reusable' => true, // cache related data | ||
'alias' => 'mechanicalParts', | ||
] | ||
); | ||
|
||
$I->assertEquals( | ||
'id', | ||
$relation->getFields() | ||
); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model\Relation :: getFields() | ||
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationGetFieldsArray(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - getFields() - array'); | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
[ | ||
'type', | ||
'name', | ||
], | ||
'robots_id', | ||
[ | ||
'reusable' => true, // cache related data | ||
'alias' => 'mechanicalParts', | ||
] | ||
); | ||
|
||
$I->assertEquals( | ||
[ | ||
'type', | ||
'name', | ||
], | ||
$relation->getFields() | ||
); | ||
} | ||
} |
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 GetOptionCest | ||
|
@@ -24,12 +25,36 @@ class GetOptionCest | |
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2018-11-13 | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationGetOption(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - getOption()'); | ||
$I->skipTest('Need implementation'); | ||
|
||
$options = [ | ||
'reusable' => true, // cache related data | ||
'alias' => 'mechanicalParts', | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
|
||
|
||
$I->assertEquals( | ||
$options['reusable'], | ||
$relation->getOption('reusable') | ||
); | ||
|
||
$I->assertEquals( | ||
$options['alias'], | ||
$relation->getOption('alias') | ||
); | ||
} | ||
} |
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 GetOptionsCest | ||
|
@@ -24,12 +25,29 @@ class GetOptionsCest | |
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2018-11-13 | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationGetOptions(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - getOptions()'); | ||
$I->skipTest('Need implementation'); | ||
|
||
$options = [ | ||
'reusable' => true, // cache related data | ||
'alias' => 'mechanicalParts', | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertEquals( | ||
$options, | ||
$relation->getOptions() | ||
); | ||
} | ||
} |
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 GetParamsCest | ||
|
@@ -24,12 +25,65 @@ class GetParamsCest | |
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2018-11-13 | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationGetParams(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - getParams()'); | ||
$I->skipTest('Need implementation'); | ||
|
||
$options = [ | ||
'reusable' => true, // cache related data | ||
'alias' => 'mechanicalParts', | ||
'params' => [ | ||
'conditions' => 'robotTypeId = :type:', | ||
'bind' => [ | ||
'type' => 4, | ||
], | ||
], | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertEquals( | ||
$options['params'], | ||
$relation->getParams() | ||
); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model\Relation :: getParams() when none are set | ||
* | ||
* @param IntegrationTester $I | ||
* | ||
* @author Sid Roberts <[email protected]> | ||
* @since 2019-04-18 | ||
*/ | ||
public function mvcModelRelationGetParamsWhenNoneSet(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model\Relation - getParams() when none are set'); | ||
|
||
$options = [ | ||
'reusable' => true, // cache related data | ||
'alias' => 'mechanicalParts', | ||
]; | ||
|
||
$relation = new Relation( | ||
Relation::HAS_MANY, | ||
'RobotsParts', | ||
'id', | ||
'robots_id', | ||
$options | ||
); | ||
|
||
$I->assertFalse( | ||
$relation->getParams() | ||
); | ||
} | ||
} |
Oops, something went wrong.