forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e32f9f
commit e77dec3
Showing
12 changed files
with
240 additions
and
3 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
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<module> | ||
<name>testnoconflict</name> | ||
<displayName><![CDATA[test no conflict]]></displayName> | ||
<version><![CDATA[1]]></version> | ||
<description><![CDATA[A module to test no override conflict]]></description> | ||
<author><![CDATA[fake_author]]></author> | ||
<tab><![CDATA[front_office_features]]></tab> | ||
<is_configurable>0</is_configurable> | ||
<need_instance>0</need_instance> | ||
<limited_countries></limited_countries> | ||
</module> |
35 changes: 35 additions & 0 deletions
35
tests/Resources/modules_tests/testnoconflict/override/classes/Cart.php
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,35 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
class Cart extends CartCore | ||
{ | ||
/** | ||
* test for override that should trigger no conflict | ||
*/ | ||
public function isCarrierInRange($id_carrier, $id_zone) | ||
{ | ||
return true; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/Resources/modules_tests/testnoconflict/testnoconflict.php
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,43 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class testnoconflict extends Module | ||
{ | ||
public function __construct() | ||
{ | ||
$this->name = 'testnoconflict'; | ||
$this->tab = 'front_office_features'; | ||
$this->version = 1.0; | ||
$this->author = 'fake author'; | ||
$this->need_instance = 0; | ||
parent::__construct(); | ||
$this->displayName = $this->l('no conflict'); | ||
$this->description = $this->l('A module to test no override conflict'); | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<module> | ||
<name>testnooverride</name> | ||
<displayName><![CDATA[test no override]]></displayName> | ||
<version><![CDATA[1]]></version> | ||
<description><![CDATA[A module to test case when there is no override]]></description> | ||
<author><![CDATA[fake_author]]></author> | ||
<tab><![CDATA[front_office_features]]></tab> | ||
<is_configurable>0</is_configurable> | ||
<need_instance>0</need_instance> | ||
<limited_countries></limited_countries> | ||
</module> |
File renamed without changes
43 changes: 43 additions & 0 deletions
43
tests/Resources/modules_tests/testnooverride/testnooverride.php
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,43 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class testnooverride extends Module | ||
{ | ||
public function __construct() | ||
{ | ||
$this->name = 'testnooverride'; | ||
$this->tab = 'front_office_features'; | ||
$this->version = 1.0; | ||
$this->author = 'fake author'; | ||
$this->need_instance = 0; | ||
parent::__construct(); | ||
$this->displayName = $this->l('no override module'); | ||
$this->description = $this->l('A module to test override check when there is no override'); | ||
} | ||
} |
Binary file not shown.
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,92 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
namespace Tests\Unit\Core\Module; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrestaShop\PrestaShop\Core\Module\ModuleOverrideChecker; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
class ModuleOverrideCheckerTest extends TestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $psOverrideDir; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $modulesTestsDir; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->psOverrideDir = dirname(__DIR__, 3) . '/Resources/modules_tests/override/'; | ||
$this->modulesTestsDir = dirname(__DIR__, 3) . '/Resources/modules_tests'; | ||
} | ||
|
||
/** | ||
* @dataProvider provideTestData | ||
*/ | ||
public function testHasOverrideConflict(string $moduleName, bool $expectedResult): void | ||
{ | ||
$moduleOverrideChecker = $this->getModuleOverrideChecker(); | ||
|
||
$moduleOverridePath = sprintf('%s/%s/override', $this->modulesTestsDir, $moduleName); | ||
|
||
$this->assertEquals($expectedResult, $moduleOverrideChecker->hasOverrideConflict($moduleOverridePath)); | ||
} | ||
|
||
private function getModuleOverrideChecker(): ModuleOverrideChecker | ||
{ | ||
$translatorMock = $this->createMock(TranslatorInterface::class); | ||
$translatorMock->method('trans')->willReturnArgument(0); | ||
|
||
return new ModuleOverrideChecker($translatorMock, $this->psOverrideDir); | ||
} | ||
|
||
public function provideTestData(): array | ||
{ | ||
return [ | ||
[ | ||
'testnoconflict', | ||
false, | ||
], | ||
[ | ||
'testnooverride', | ||
false, | ||
], | ||
[ | ||
'testbasicconflict', | ||
true, | ||
], | ||
[ | ||
'testtrickyconflict', | ||
true, | ||
], | ||
]; | ||
} | ||
} |