-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for MarketplaceSourceProvider class
- Loading branch information
1 parent
056d93f
commit efaf05e
Showing
4 changed files
with
232 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
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,122 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<modules><module> | ||
<id>5496</id> | ||
<name>autoupgrade</name> | ||
<displayName>1-Click Upgrade</displayName> | ||
<categoryName><![CDATA[Data migration & Backup]]></categoryName> | ||
<description> | ||
Upgrade to the latest version of PrestaShop in a few clicks, thanks to this automated method | ||
</description> | ||
<author>PrestaShop</author> | ||
<img>https://medias1.prestastore.com/img/pico/5496.jpg</img> | ||
<description_full> | ||
Upgrade to the latest version of PrestaShop in a few clicks, thanks to this automated method. | ||
</description_full> | ||
<additional_description> | ||
Use this native module to:Keep your store up-to-date: benefit from the latest features and improvements available.Protect your store: stay up-to-date with the latest on security for modules you have downloaded from PrestaShop Addons. | ||
</additional_description> | ||
<tab>migration_tools</tab> | ||
<version>6.0.0</version> | ||
<compatibility> | ||
<from>1.7.0.0</from> | ||
<to>8.1.7</to> | ||
</compatibility> | ||
<price> | ||
<EUR>0</EUR> | ||
<USD>0</USD> | ||
<GBP>0</GBP> | ||
</price> | ||
<badges> | ||
<badge label="Made by PrestaShop"> | ||
https://medias2.prestastore.com/themes/prestastore/img/front/sprites/badges/made-by-prestashop.png | ||
</badge> | ||
</badges> | ||
<cover> | ||
<small> | ||
https://addons.prestashop.com/1630684-pprod/1-click-upgrade.jpg | ||
</small> | ||
<big> | ||
https://addons.prestashop.com/1630684-pbig/1-click-upgrade.jpg | ||
</big> | ||
</cover> | ||
</module> | ||
<module> | ||
<id>9131</id> | ||
<name>blockwishlist</name> | ||
<displayName>Wishlist block</displayName> | ||
<categoryName>Non téléchargeables</categoryName> | ||
<description> | ||
Allow customers to create wishlists to save their favorite products for later | ||
</description> | ||
<author>PrestaShop</author> | ||
<img>https://medias1.prestastore.com/img/pico/9131.jpg</img> | ||
<description_full> | ||
Allow customers to create wishlists to save their favorite products for later. | ||
</description_full> | ||
<tab></tab> | ||
<version>3.0.1</version> | ||
<compatibility> | ||
<from>8.0.0</from> | ||
<to>8.1.7</to> | ||
</compatibility> | ||
<price> | ||
<EUR>0</EUR> | ||
<USD>0</USD> | ||
<GBP>0</GBP> | ||
</price> | ||
<badges> | ||
<badge label="Made by PrestaShop"> | ||
https://medias2.prestastore.com/themes/prestastore/img/front/sprites/badges/made-by-prestashop.png | ||
</badge> | ||
</badges> | ||
<cover> | ||
<small> | ||
https://addons.prestashop.com/1483984-pprod/wishlist-block.jpg | ||
</small> | ||
<big> | ||
https://addons.prestashop.com/1483984-pbig/wishlist-block.jpg | ||
</big> | ||
</cover> | ||
</module> | ||
<module> | ||
<id>9144</id> | ||
<name>productcomments</name> | ||
<displayName>Product Comments</displayName> | ||
<categoryName>Non téléchargeables</categoryName> | ||
<description> | ||
Allow users to post reviews on your products and/or rate them based on specific criteria | ||
</description> | ||
<author>PrestaShop</author> | ||
<img>https://medias1.prestastore.com/img/pico/9144.jpg</img> | ||
<description_full> | ||
Allow users to post reviews on your products and/or rate them based on specific criteria. | ||
</description_full> | ||
<additional_description> | ||
Use this native module to:Boost your sales: increase your conversion rate with a comments section, helpful to reassure and show your visitors your store is trustworthy.Improve your SEO: search engines will use it to discover new content.Rich snippets: enrich your search engine results by displaying rating stars on your store - it allows you to gain visibility, and therefore increase your traffic. | ||
</additional_description> | ||
<tab></tab> | ||
<version>6.0.2</version> | ||
<compatibility> | ||
<from>1.7.7.0</from> | ||
<to>8.1.7</to> | ||
</compatibility> | ||
<price> | ||
<EUR>0</EUR> | ||
<USD>0</USD> | ||
<GBP>0</GBP> | ||
</price> | ||
<badges> | ||
<badge label="Made by PrestaShop"> | ||
https://medias2.prestastore.com/themes/prestastore/img/front/sprites/badges/made-by-prestashop.png | ||
</badge> | ||
</badges> | ||
<cover> | ||
<small> | ||
https://addons.prestashop.com/1430579-pprod/product-comments.jpg | ||
</small> | ||
<big> | ||
https://addons.prestashop.com/1430579-pbig/product-comments.jpg | ||
</big> | ||
</cover> | ||
</module> | ||
</modules> |
97 changes: 97 additions & 0 deletions
97
tests/unit/UpgradeTools/Module/Source/Provider/MarketplaceSourceProviderTest.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,97 @@ | ||
<?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 Academic Free License 3.0 (AFL-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/AFL-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/AFL-3.0 Academic Free License 3.0 (AFL-3.0) | ||
*/ | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrestaShop\Module\AutoUpgrade\Parameters\FileConfigurationStorage; | ||
use PrestaShop\Module\AutoUpgrade\UpgradeTools\Module\Source\ModuleSource; | ||
use PrestaShop\Module\AutoUpgrade\UpgradeTools\Module\Source\Provider\MarketplaceSourceProvider; | ||
use PrestaShop\Module\AutoUpgrade\Xml\FileLoader; | ||
|
||
class MarketplaceSourceProviderTest extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
if (PHP_VERSION_ID >= 80000) { | ||
$this->markTestSkipped('An issue with this version of PHPUnit and PHP 8+ prevents this test to run.'); | ||
} | ||
} | ||
|
||
public function testCacheGenerationWithData() | ||
{ | ||
$fileLoader = $this->createMock(FileLoader::class); | ||
$fileLoader->method('getXmlFile')->willReturn(simplexml_load_file(__DIR__ . '/../../../../../fixtures/api-marketplace/native-modules-list.xml')); | ||
$fileConfigurationStorageMock = $this->createMock(FileConfigurationStorage::class); | ||
|
||
$sourceProvider = new MarketplaceSourceProvider('9.0.0', 'C:\mocked', $fileLoader, $fileConfigurationStorageMock); | ||
|
||
$fileConfigurationStorageMock->expects($this->once())->method('exists'); | ||
$fileConfigurationStorageMock->expects($this->once())->method('save'); | ||
$fileConfigurationStorageMock->expects($this->never())->method('load'); | ||
|
||
$results1 = $sourceProvider->getUpdatesOfModule('blockwishlist', '0.9.0'); | ||
$results2 = $sourceProvider->getUpdatesOfModule('blockwishlist', '0.9.0'); | ||
|
||
$this->assertEquals($results1, $results2); | ||
$this->assertEquals([ | ||
new ModuleSource('blockwishlist', '3.0.1', 'https://api.addons.prestashop.com/?id_module=9131&method=module&version=9.0.0', true), | ||
], $results2); | ||
} | ||
|
||
public function testCacheGenerationWithNoData() | ||
{ | ||
$fileLoader = $this->createMock(FileLoader::class); | ||
$fileLoader->method('getXmlFile')->willReturn(simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><modules></modules>')); | ||
$fileConfigurationStorageMock = $this->createMock(FileConfigurationStorage::class); | ||
|
||
$sourceProvider = new MarketplaceSourceProvider('9.0.0', 'C:\mocked', $fileLoader, $fileConfigurationStorageMock); | ||
|
||
$fileConfigurationStorageMock->expects($this->once())->method('exists'); | ||
$fileConfigurationStorageMock->expects($this->once())->method('save'); | ||
$fileConfigurationStorageMock->expects($this->never())->method('load'); | ||
|
||
$sourceProvider->getUpdatesOfModule('test1', '1.0.0'); | ||
$sourceProvider->getUpdatesOfModule('test2', '1.0.0'); | ||
} | ||
|
||
public function testCacheLoading() | ||
{ | ||
$fileLoader = $this->createMock(FileLoader::class); | ||
$fileConfigurationStorageMock = $this->createMock(FileConfigurationStorage::class); | ||
$fileConfigurationStorageMock->method('exists')->willReturn(true); | ||
$fileConfigurationStorageMock->method('load')->willReturn([]); | ||
|
||
$sourceProvider = new MarketplaceSourceProvider('9.0.0', 'C:\mocked', $fileLoader, $fileConfigurationStorageMock); | ||
|
||
$fileConfigurationStorageMock->expects($this->once())->method('exists'); | ||
$fileConfigurationStorageMock->expects($this->once())->method('load'); | ||
$fileConfigurationStorageMock->expects($this->never())->method('save'); | ||
|
||
$sourceProvider->getUpdatesOfModule('test1', '1.0.0'); | ||
$sourceProvider->getUpdatesOfModule('test2', '1.0.0'); | ||
} | ||
} |