Skip to content

Commit

Permalink
OXDEV-6932: Use assign instead of directly change property
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Jul 14, 2023
1 parent 4a14890 commit 8737ef9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function testGetId()
public function testGetCountryId()
{
$oUser = oxNew(User::class);
$oUser->oxuser__oxcountryid = new Field('a7c40f631fc920687.20179984');
$oUser->assign(['oxcountryid' => 'a7c40f631fc920687.20179984']);
$oUser->save();

$session = Registry::getSession();
$session->setUser($oUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class IncorrectVATArticlesMessageFormatterTest extends TestCase
public function testGetMessage()
{
$oArticle = oxNew(Article::class);
$oArticle->oxarticles__oxtitle = new Field('some other name', Field::T_RAW);
$oArticle->assign(['oxtitle' => 'some other name']);
$oArticle->save();

/** @var IncorrectVATArticlesMessageFormatter $oVATTBEArticleMessageFormer */
$oVATTBEArticleMessageFormer = oxNew(IncorrectVATArticlesMessageFormatter::class);
Expand Down
7 changes: 4 additions & 3 deletions tests/Integration/Model/UserSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace OxidEsales\EVatModule\Tests\Integration\Model;

use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Field;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EVatModule\Model\Evidence\Item\BillingCountryEvidence;
use OxidEsales\EVatModule\Model\Evidence\Item\GeoLocationEvidence;
Expand Down Expand Up @@ -49,7 +48,8 @@ public function testTBEEvidenceListCaching()
$moduleSettings->saveDefaultEvidence('billing_country');

$oUser = oxNew(EShopUser::class);
$oUser->oxuser__oxcountryid = new Field('GermanyId');
$oUser->assign(['oxcountryid' => 'GermanyId']);
$oUser->save();
Registry::getSession()->setUser($oUser);

/** @var User $oTBEUser */
Expand All @@ -59,7 +59,8 @@ public function testTBEEvidenceListCaching()
$moduleSettings->saveEvidenceClasses([GeoLocationEvidence::class]);
$moduleSettings->saveDefaultEvidence('geo_location');

$oUser->oxuser__oxcountryid = new Field('LithuaniaId');
$oUser->assign(['oxcountryid' => 'LithuaniaId']);
$oUser->save();

$aExpectedList = [
'billing_country' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Shop/BasketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public function testSetCountryIdOnChangeEventWhenMessageShouldBeShown($bAddToBas
/** @var Country $oCountry */
$oCountry = oxNew(Country::class);
$oCountry->load($sLithuaniaId);
$oCountry->oxcountry__oevattbe_appliestbevat = new Field(true);
$oCountry->assign(['oevattbe_appliestbevat' => true]);
$oCountry->save();

/** @var Article $oArticle */
$oArticle = oxNew(Article::class);
$oArticle->setId('_testArticle1');
$oArticle->oxarticles__oevattbe_istbeservice = new Field(true);
$oCountry->assign(['oevattbe_istbeservice' => true]);
$oArticle->save();

/** @var EShopBasket|Basket $oBasket */
Expand Down
6 changes: 4 additions & 2 deletions tests/Integration/Shop/CategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class CategoryTest extends TestCase
public function testIsOEVATTBETBE()
{
$oCategory = oxNew(Category::class);
$oCategory->oxcategories__oevattbe_istbe = new Field(1);
$oCategory->assign(['oevattbe_istbe' => 1]);
$oCategory->save();
$this->assertTrue($oCategory->isOeVATTBETBE());

$oCategory->oxcategories__oevattbe_istbe = new Field(0);
$oCategory->assign(['oevattbe_istbe' => 0]);
$oCategory->save();
$this->assertFalse($oCategory->isOeVATTBETBE());
}
}
15 changes: 10 additions & 5 deletions tests/Integration/Shop/CountryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class CountryTest extends TestCase
public function testAppliesOeTBEVATTbeVat()
{
$oCountry = oxNew(Country::class);
$oCountry->oxcountry__oevattbe_appliestbevat = new Field(1);
$oCountry->assign(['oevattbe_appliestbevat' => 1]);
$oCountry->save();
$this->assertTrue($oCountry->appliesOeTBEVATTbeVat());

$oCountry->oxcountry__oevattbe_appliestbevat = new Field(0);
$oCountry->assign(['oevattbe_appliestbevat' => 0]);
$oCountry->save();
$this->assertFalse($oCountry->appliesOeTBEVATTbeVat());
}

Expand All @@ -34,10 +36,12 @@ public function testAppliesOeTBEVATTbeVat()
public function testIsOEVATTBEAtLeastOneGroupConfigured()
{
$oCountry = oxNew(Country::class);
$oCountry->oxcountry__oevattbe_istbevatconfigured = new Field(1);
$oCountry->assign(['oevattbe_istbevatconfigured' => 1]);
$oCountry->save();
$this->assertTrue($oCountry->isOEVATTBEAtLeastOneGroupConfigured());

$oCountry->oxcountry__oevattbe_istbevatconfigured = new Field(0);
$oCountry->assign(['oevattbe_istbevatconfigured' => 0]);
$oCountry->save();
$this->assertFalse($oCountry->isOEVATTBEAtLeastOneGroupConfigured());
}

Expand All @@ -47,7 +51,8 @@ public function testIsOEVATTBEAtLeastOneGroupConfigured()
public function testGetOeVATTBEName()
{
$oCountry = oxNew(Country::class);
$oCountry->oxcountry__oxtitle = new Field('LT');
$oCountry->assign(['oxtitle' => 'LT']);
$oCountry->save();
$this->assertSame('LT', $oCountry->getOeVATTBEName());
}
}

0 comments on commit 8737ef9

Please sign in to comment.