-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OXDEV-665 fix __isset function in BaseModel
- Loading branch information
1 parent
0bf1ecf
commit 71e9310
Showing
7 changed files
with
294 additions
and
63 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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\EshopCommunity\Tests\Integration\Core\Model; | ||
|
||
use OxidEsales\TestingLibrary\UnitTestCase; | ||
use OxidEsales\Eshop\Application\Model\Article; | ||
|
||
/** | ||
* Class OxidEsales\EshopCommunity\Core\Model\BaseModelTest | ||
*/ | ||
class BaseModelTest extends UnitTestCase | ||
{ | ||
public function testFunctionIsPropertyLoadedReturnsFalseWhenPropertyIsNotLoadedAndIsField() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$this->assertFalse($model->isPropertyLoaded($fieldName)); | ||
} | ||
|
||
public function testFunctionIsPropertyLoadedReturnsTrueWhenPropertyIsLoadedAndIsField() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$model->$fieldName; | ||
|
||
$this->assertTrue($model->isPropertyLoaded($fieldName)); | ||
} | ||
|
||
public function testLazyLoadingMagicIssetReturnsTrueWhenPropertyIsNotLoadedAndIsField() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$this->assertTrue(isset($model->$fieldName)); | ||
} | ||
|
||
public function testLazyLoadingMagicIssetLoadsPropertyWhenPropertyIsNotLoadedAndIsField() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$this->assertTrue(isset($model->$fieldName)); | ||
} | ||
|
||
public function testLazyLoadingMagicIssetReturnsTrueWhenPropertyIsLoadedAndIsField() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$model->$fieldName; | ||
|
||
$this->assertTrue(isset($model->$fieldName)); | ||
} | ||
|
||
public function testLazyLoadingMagicIssetOnValueOfFieldReturnsTrueWhenFieldIsNotLoaded() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$this->assertTrue(isset($model->$fieldName->value)); | ||
} | ||
|
||
public function testLazyLoadingMagicIssetOnValueOfFieldReturnsTrueWhenFieldIsLoaded() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
$fieldName = $this->getTestFieldNameOfModelWithLazyLoading(); | ||
|
||
$model->$fieldName; | ||
|
||
$this->assertTrue(isset($model->$fieldName->value)); | ||
} | ||
|
||
public function testLazyLoadingMagicIssetOnValueOfPropertyReturnsFalseWhenPropertyIsNotFieldAndNotLoaded() | ||
{ | ||
$model = $this->getModelWithLazyLoading(); | ||
|
||
$this->assertFalse(isset($model->someProperty->value)); | ||
} | ||
|
||
private function getModelWithLazyLoading() | ||
{ | ||
$model = oxNew(Article::class); | ||
$model->init("oxarticles"); | ||
$model->load(2000); | ||
|
||
return $model; | ||
} | ||
|
||
private function getTestFieldNameOfModelWithLazyLoading() | ||
{ | ||
return 'oxarticles__oxartnum'; | ||
} | ||
} |
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
Oops, something went wrong.