Skip to content

Commit

Permalink
Merge branch 'b-7.1.x' into b-7.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieg committed May 28, 2024
2 parents 877918a + b904c3f commit b8eb50d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-7.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
### Deprecated
- Deprecated the `BasicContextInterface::getCurrentShopId`. Use the `ContextInterface::getCurrentShopId` instead.

### Fixed
- Wrong path calculated for custom theme translations directory [PR-963](https://github.com/OXID-eSales/oxideshop_ce/pull/963) [#0007386](https://bugs.oxid-esales.com/view.php?id=7386) [#0007643](https://bugs.oxid-esales.com/view.php?id=7643)
- Fix group delete result calculation [PR-962](https://github.com/OXID-eSales/oxideshop_ce/pull/962)

## v7.1.0 - 2024-03-18

### Added
Expand Down
7 changes: 3 additions & 4 deletions source/Application/Model/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public function delete($sOXID = null)
return false;
}

parent::delete($sOXID);

$parentResult = parent::delete($sOXID);
$oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

// deleting related data records
Expand All @@ -68,10 +67,10 @@ public function delete($sOXID = null)
]);

$sDelete = 'delete from oxobject2payment where oxobject2payment.oxobjectid = :oxid';
$rs = $oDb->execute($sDelete, [
$oDb->execute($sDelete, [
':oxid' => $sOXID
]);

return $rs->EOF;
return $parentResult;
}
}
2 changes: 1 addition & 1 deletion source/Core/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ protected function getCustomThemeLanguageFiles($language)
$aLangFiles = [];

if ($sCustomTheme) {
$customThemePath = $sAppDir . 'views/' . $sCustomTheme;
$customThemePath = $sAppDir . 'views/' . $sCustomTheme .'/';
$aLangFiles = array_merge($aLangFiles, $this->getThemeLanguageFiles($customThemePath, $sLang));
}

Expand Down
66 changes: 66 additions & 0 deletions tests/Integration/Application/Model/GroupsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

namespace OxidEsales\EshopCommunity\Tests\Integration\Application\Model;

use OxidEsales\Eshop\Application\Model\Groups;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Field;
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;

class GroupsTest extends IntegrationTestCase
{
protected $relatedRecords = [
'oxobject2delivery' => ['oxobjectid', ''],
'oxobject2discount' => ['oxobjectid', ''],
'oxobject2group' => ['oxgroupsid', ''],
'oxobject2payment' => ['oxobjectid', '']
];

public function setUp(): void
{
parent::setUp();

$groupsModel = oxNew(Groups::class);
$groupsModel->setId('testgroup');
$groupsModel->oxgroups__oxtitle = new Field('testgroup');
$groupsModel->oxgroups__oxactive = new Field(1);
$groupsModel->save();
}

public function testDelete()
{
$db = DatabaseProvider::getDb();

// selecting count from DB
$groupsModel = oxNew(Groups::class);
$groupsModel->load('testgroup');

$result = $groupsModel->delete();
$this->assertTrue($result);

// checking if group is deleted from DB
$groupId = $groupsModel->getId();
$query = "select count(*) from oxgroups where oxid = '$groupId' ";

$this->assertSame(0, $db->getOne($query), 'item from oxgroups are not deleted');

// checking related records
foreach ($this->relatedRecords as $sTable => $aField) {
$sField = $aField[0];

$query = "select count(*) from $sTable where $sTable.$sField = '$groupId' ";
$this->assertSame(0, $db->getOne($query), 'item from ' . $sTable . ' are not deleted');
}
}

public function testDeleteNoId()
{
$groupsModel = oxNew(Groups::class);
$this->assertFalse($groupsModel->delete());
}
}

0 comments on commit b8eb50d

Please sign in to comment.