Skip to content

Commit

Permalink
OXDEV-8234 Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaIvanovski committed May 27, 2024
1 parent 2af33cf commit e6596e9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Component/UserComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OxidEsales\GeoBlocking\Component;

use OxidEsales\GeoBlocking\Model\Address;
use OxidEsales\Eshop\Application\Model\Address;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\GeoBlocking\Service\CountryToShopService;

Expand Down
8 changes: 0 additions & 8 deletions tests/Codeception/Acceptance/FrontendCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ class FrontendCest
{
public function _before(AcceptanceTester $I)
{
$I->setModuleActive();

$I->deleteFromDatabase('oxarticles', ['OXID' => '1000']);
$I->deleteFromDatabase('oxuser', ['OXID' => 'oegeoblockingtestuser']);
$I->deleteFromDatabase('oxuser', ['OXUSERNAME' => '[email protected]']);
$I->deleteFromDatabase('oxaddress', ['OXID' => 'pickup_address_id']);
$I->deleteFromDatabase('oxaddress', ['OXID' => 'user_defined_pickup_address_id']);
$I->haveInDatabase('oegeoblocking_country_to_shop', Fixtures::get('countryToShopData'));
$I->updateConfigInDatabase('stickyHeader', false, 'bool');
}

public function registerUserWithCountryWhichIsInvoiceOnly(AcceptanceTester $I)
Expand Down
8 changes: 0 additions & 8 deletions tests/Codeception/Support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,4 @@ public function openShop()
$I->amOnPage($homePage->URL);
return $homePage;
}

public function setModuleActive(): void
{
ContainerFactory::getInstance()
->getContainer()
->get(ModuleActivationBridgeInterface::class)
->activate('oegeoblocking', 1);
}
}
9 changes: 5 additions & 4 deletions tests/Integration/Component/UserComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use OxidEsales\Eshop\Application\Component\UserComponent;
use OxidEsales\GeoBlocking\Model\Address;
use OxidEsales\Eshop\Application\Model\Address as EShopAddress;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Field;
use OxidEsales\Eshop\Core\Registry;
Expand All @@ -29,11 +30,11 @@ protected function setUp(): void
$countryToShop->oegeoblocking_country_to_shop__invoice_only = new Field(1);
$countryToShop->save();

$address = new Address();
$address = new EShopAddress();
$address->setId('address_id');
$address->save();

$address2 = new Address();
$address2 = new EShopAddress();
$address2->setId('address_id2');
$address2->save();
}
Expand All @@ -55,7 +56,7 @@ public function testChangeUserWithoutRedirectWhenNotAllowedToChangeAddressData()
->onlyMethods(['oeGeoBlockingIsUserChangingAddress'])
->getMock();
$addressMock->method('oeGeoBlockingIsUserChangingAddress')->willReturn(true);
Registry::set(Address::class, $addressMock);
Registry::set(EShopAddress::class, $addressMock);

$this->assertFalse($userComponent->changeUserWithoutRedirect());
$errors = Registry::getSession()->getVariable('Errors');
Expand All @@ -72,7 +73,7 @@ public function testChangeUserWithoutRedirectWhenAllowedToChangeAddressData()
->onlyMethods(['oeGeoBlockingIsUserChangingAddress'])
->getMock();
$addressMock->method('oeGeoBlockingIsUserChangingAddress')->willReturn(false);
Registry::set(Address::class, $addressMock);
Registry::set(EShopAddress::class, $addressMock);

$this->assertNotFalse($userComponent->changeUserWithoutRedirect());
$errors = Registry::getSession()->getVariable('Errors');
Expand Down
4 changes: 4 additions & 0 deletions tests/Integration/Model/UserAddressListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ protected function setUp(): void

$user = new User();
$user->setId('user_id');
$user->assign([
'oxusername' => 'test',
'oxpassword' => md5('test')
]);
$user->save();

$countryToShop = new CountryToShop();
Expand Down

0 comments on commit e6596e9

Please sign in to comment.