Skip to content

Commit

Permalink
OXDEV-8234 Fixed integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
RahatHameed committed May 14, 2024
1 parent 83e64da commit d7446e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions tests/Integration/Component/UserComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
namespace OxidEsales\GeoBlocking\Tests\Integration\Component;

use OxidEsales\Eshop\Application\Component\UserComponent;
use OxidEsales\Eshop\Application\Model\Address;
use OxidEsales\Eshop\Application\Model\Address as EshopAddess;
use OxidEsales\GeoBlocking\Model\Address ;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Field;
use OxidEsales\Eshop\Core\Registry;
Expand Down Expand Up @@ -48,13 +49,14 @@ public function testChangeUserWithoutRedirectWhenNotAllowedToChangeAddressData()
/** @var \OxidEsales\GeoBlocking\Component\UserComponent $userComponent */
$userComponent = oxNew(UserComponent::class);
$_GET['oxaddressid'] = 'address_id';
$_GET['deladr'] = 'test';

$addressMock = $this->getMockBuilder(Address::class)
->setMethods(['oeGeoBlockingIsUserChangingAddress'])
->onlyMethods(['oeGeoBlockingIsUserChangingAddress'])
->getMock();
$addressMock->method('oeGeoBlockingIsUserChangingAddress')->willReturn(true);
Registry::set(Address::class, $addressMock);

Registry::set(EshopAddess::class, $addressMock);
$this->assertFalse($userComponent->changeUserWithoutRedirect());
$errors = Registry::getSession()->getVariable('Errors');
$this->assertSame(1, count($errors));
Expand All @@ -67,10 +69,10 @@ public function testChangeUserWithoutRedirectWhenAllowedToChangeAddressData()
$_GET['oxaddressid'] = 'address_id';

$addressMock = $this->getMockBuilder(Address::class)
->setMethods(['oeGeoBlockingIsUserChangingAddress'])
->onlyMethods(['oeGeoBlockingIsUserChangingAddress'])
->getMock();
$addressMock->method('oeGeoBlockingIsUserChangingAddress')->willReturn(false);
Registry::set(Address::class, $addressMock);
Registry::set(EshopAddess::class, $addressMock);

$this->assertNotFalse($userComponent->changeUserWithoutRedirect());
$errors = Registry::getSession()->getVariable('Errors');
Expand Down Expand Up @@ -105,6 +107,8 @@ private function createActiveUser()
{
$user = new User();
$user->setId('user_id');
$user->assign(['oxpassword' => 'test']);
$user->assign(['oxusername' => 'test']);
$user->save();
Registry::getSession()->setVariable('usr', 'user_id');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Core/InputValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function setUp(): void
$address2->save();
}

public function checkoutCountriesProvider()
public static function checkoutCountriesProvider()
{
return [
[['oxuser__oxcountryid' => 'country_id'], ['oxaddress__oxcountryid' => 'country_id']],
Expand Down

0 comments on commit d7446e6

Please sign in to comment.