Initial commit

This commit is contained in:
2019-11-20 07:44:43 +01:00
commit 5bf49c4a81
41188 changed files with 5459177 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\Cookie;
class CookieTest extends TestCase
{
const MY_TEST_KEY = 'wololo';
private $cookie;
protected function setUp()
{
parent::setUp();
$this->cookie = new Cookie('admin', sys_get_temp_dir());
$this->assertTrue($this->cookie->storeKey(self::MY_TEST_KEY));
}
public function testKeyIsGenerated()
{
$this->assertSame(self::MY_TEST_KEY, $this->cookie->readKey());
}
public function testPermissionGranted()
{
$fakeCookie = [
'id_employee' => 2,
'autoupgrade' => md5(md5(self::MY_TEST_KEY) . md5(2)),
];
$this->assertTrue($this->cookie->check($fakeCookie));
}
public function testPermissionRefused()
{
$fakeCookie = [
'id_employee' => 2,
'autoupgrade' => 'IHaveNoIdeaWhatImDoing',
];
$this->assertFalse($this->cookie->check($fakeCookie));
}
}

View File

@@ -0,0 +1,63 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\Log\LegacyLogger;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
use PrestaShop\Module\AutoUpgrade\UpgradeTools\CoreUpgrader\CoreUpgrader17;
class CoreUpgraderTest extends TestCase
{
protected $coreUpgrader;
protected function setUp()
{
parent::setUp();
$stub = $this->getMockBuilder(UpgradeContainer::class)
->disableOriginalConstructor()
->getMock();
$this->coreUpgrader = new CoreUpgrader17($stub, new LegacyLogger());
}
/**
* @dataProvider versionProvider
*/
public function testVersionNormalization($source, $expected)
{
$this->assertSame($expected, $this->coreUpgrader->normalizeVersion($source));
}
public function versionProvider()
{
return array(
array('1.7', '1.7.0.0'),
array('1.7.2', '1.7.2.0'),
array('1.6.1.0-beta', '1.6.1.0-beta'),
array('1.6.1-beta', '1.6.1-beta.0'), // Weird, but still a test
);
}
}

View File

@@ -0,0 +1,89 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\ErrorHandler;
use PrestaShop\Module\AutoUpgrade\Log\LegacyLogger;
class ErrorHandlerTest extends TestCase
{
protected $errorHandler;
protected $adminSelfUpgradeStub;
protected $logger;
protected function setUp()
{
parent::setUp();
$this->logger = new LegacyLogger();
$this->errorHandler = new ErrorHandler($this->logger);
}
public function testDefaultContentIsEmpty()
{
$this->assertEmpty($this->logger->getErrors());
}
public function testCheckExceptionAndContent()
{
$exception = new Exception('ERMAGHERD');
$line = __LINE__ - 1;
// The exception will be sent to the stdout,
// we enable the output buffering
ob_start();
$this->errorHandler->exceptionHandler($exception);
ob_end_clean();
$errors = $this->logger->getErrors();
$this->assertCount(1, $errors);
$this->assertContains('[INTERNAL] ' . __FILE__ . ' line ' . $line . ' - Exception: ERMAGHERD', end($errors));
}
public function testWarningInErrorHandler()
{
$line = __LINE__;
$this->errorHandler->errorHandler(E_WARNING, 'Trololo', __FILE__, $line);
$msgs = $this->logger->getInfos();
$this->assertCount(0, $this->logger->getErrors());
$this->assertCount(1, $msgs);
$this->assertSame(end($msgs), '[INTERNAL] ' . __FILE__ . ' line ' . $line . ' - Trololo');
}
/**
* @dataProvider logProvider
*/
public function testGeneratedJsonLog($log)
{
$this->assertNotNull(json_decode($this->errorHandler->generateJsonLog($log)));
}
public function logProvider()
{
return array(
array("[INTERNAL] /var/www/html/modules/autoupgrade/classes/TaskRunner/Upgrade/BackupFiles.php line 55 - Class 'PrestaShop\Module\AutoUpgrade\TaskRunner\Upgrade\UpgradeContainer' not found"),
array("[INTERNAL] /var/www/html/modules/autoupgrade/classes/TaskRunner/Upgrade/BackupDb.php line 105 - Can't use method return value in write context"),
);
}
}

View File

@@ -0,0 +1,158 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
class FilesystemAdapterTest extends TestCase
{
private $container;
private $filesystemAdapter;
protected function setUp()
{
parent::setUp();
$this->container = new UpgradeContainer('/html', '/html/admin');
// We expect in these tests to NOT update the theme
$this->container->getUpgradeConfiguration()->set('PS_AUTOUP_UPDATE_DEFAULT_THEME', false);
$this->filesystemAdapter = $this->container->getFilesystemAdapter();
}
/**
* @dataProvider ignoredFilesProvider
*/
public function testFileIsIgnored($file, $fullpath, $process)
{
$this->assertTrue(
$this->filesystemAdapter->isFileSkipped(
$file,
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH) . $fullpath,
$process));
}
/**
* When we list the files to get from a release, we are not working in the current shop.
* Paths mismatch but we should expect the same results.
*
* @dataProvider ignoredFilesProvider
*/
public function testFileFromReleaseIsIgnored($file, $fullpath, $process)
{
$this->assertTrue(
$this->filesystemAdapter->isFileSkipped(
$file,
$this->container->getProperty(UpgradeContainer::LATEST_PATH) . $fullpath,
$process,
$this->container->getProperty(UpgradeContainer::LATEST_PATH)
));
}
/**
* @dataProvider notIgnoredFilesProvider
*/
public function testFileIsNotIgnored($file, $fullpath, $process)
{
$this->assertFalse(
$this->filesystemAdapter->isFileSkipped(
$file,
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH) . $fullpath,
$process));
}
public function ignoredFilesProvider()
{
return array(
array('.git', '/.git', 'upgrade'),
array('autoupgrade', '/admin/autoupgrade', 'upgrade'),
array('autoupgrade', '/admin/autoupgrade', 'restore'),
array('autoupgrade', '/admin/autoupgrade', 'backup'),
array('autoupgrade', '/modules/autoupgrade', 'upgrade'),
array('autoupgrade', '/modules/autoupgrade', 'restore'),
array('autoupgrade', '/modules/autoupgrade', 'backup'),
array('parameters.yml', '/app/config/parameters.yml', 'upgrade'),
array('classic', '/themes/classic', 'upgrade'),
);
}
public function notIgnoredFilesProvider()
{
return array(
array('parameters.yml', '/app/config/parameters.yml', 'backup'),
array('doge.txt', '/doge.txt', 'upgrade'),
array('parameters.yml', '/parameters.yml', 'upgrade'),
array('parameters.yml.dist', '/app/config/parameters.yml.dist', 'upgrade'),
);
}
public function testRandomFolderIsNotAPrestashopRelease()
{
$this->assertFalse(
$this->filesystemAdapter->isReleaseValid(__DIR__)
);
}
public function testTempFolderIsAPrestashopRelease()
{
// Create temp folder and fill it with the needed files
$folder = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'PSA' . mt_rand(100, 2000);
$this->fillFolderWithPsAssets($folder);
$this->assertTrue(
$this->filesystemAdapter->isReleaseValid($folder)
);
}
/**
* Weird case where we have a file instead of a folder.
*/
public function testTempFolderIsNotAPrestashopReleaseAfterChanges()
{
// Create temp folder and fill it with the needed files
$folder = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'PSA' . mt_rand(100, 2000);
$this->fillFolderWithPsAssets($folder);
rmdir($folder . DIRECTORY_SEPARATOR . 'classes');
touch($folder . DIRECTORY_SEPARATOR . 'classes');
$this->assertFalse(
$this->filesystemAdapter->isReleaseValid($folder)
);
}
protected function fillFolderWithPsAssets($folder)
{
mkdir($folder);
mkdir($folder . DIRECTORY_SEPARATOR . 'classes');
mkdir($folder . DIRECTORY_SEPARATOR . 'config');
touch($folder . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'defines.inc.php');
mkdir($folder . DIRECTORY_SEPARATOR . 'controllers');
touch($folder . DIRECTORY_SEPARATOR . 'index.php');
}
}

View File

@@ -0,0 +1,73 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\Log\LegacyLogger;
class LegacyLoggerTest extends TestCase
{
public function testLastInfoIsRegistered()
{
$logger = new LegacyLogger();
$logger->log(LegacyLogger::INFO, 'Hello');
$this->assertSame('Hello', $logger->getLastInfo());
}
public function testSeveralLastInfoAreRegistered()
{
$logger = new LegacyLogger();
$logger->log(LegacyLogger::INFO, 'Hello');
$logger->log(LegacyLogger::INFO, 'Good bye');
$this->assertSame('Good bye', $logger->getLastInfo());
$infos = $logger->getInfos();
$this->assertSame('Hello', end($infos));
$this->assertCount(1, $infos);
}
public function testErrorIsRegistered()
{
$logger = new LegacyLogger();
$logger->log(LegacyLogger::CRITICAL, 'Ach!!!');
$errors = $logger->getErrors();
$this->assertCount(1, $errors);
$this->assertCount(0, $logger->getInfos());
$this->assertSame('Ach!!!', end($errors));
}
public function testMessageIsRegistered()
{
$logger = new LegacyLogger();
$logger->log(LegacyLogger::DEBUG, 'Some stuff happened');
$messages = $logger->getInfos();
$this->assertCount(1, $messages);
$this->assertCount(0, $logger->getErrors());
$this->assertSame('Some stuff happened', end($messages));
}
}

View File

@@ -0,0 +1,68 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\PrestashopConfiguration;
class PrestaShopConfigurationTest extends TestCase
{
public function testPrestaShopVersionInFile()
{
$class = new PrestashopConfiguration(__DIR__, __DIR__);
$content = "<?php
define('_DB_SERVER_', '127.0.0.1:3306');
define('_DB_NAME_', 'prestashop');
define('_DB_USER_', 'root');
define('_DB_PASSWD_', 'admin');
define('_DB_PREFIX_', 'ps_');
define('_MYSQL_ENGINE_', 'InnoDB');
define('_PS_CACHING_SYSTEM_', 'CacheMemcache');
define('_PS_CACHE_ENABLED_', '0');
define('_COOKIE_KEY_', 'hgfdsq');
define('_COOKIE_IV_', 'mAJLfCuY');
define('_PS_CREATION_DATE_', '2018-03-16');
if (!defined('_PS_VERSION_'))
define('_PS_VERSION_', '1.6.1.18');
define('_RIJNDAEL_KEY_', 'dfv');
define('_RIJNDAEL_IV_', 'fdfd==');";
$this->assertSame('1.6.1.18', $class->findPrestaShopVersionInFile($content));
}
/**
* From PrestaShop 1.7.5.0, the version is stored in the class AppKernel
*/
public function testPrestaShopVersionInAppKernel()
{
$class = new PrestashopConfiguration(__DIR__, __DIR__);
$this->assertSame(
'1.7.6.0',
$class->findPrestaShopVersionInFile(
file_get_contents(__DIR__ . '/fixtures/AppKernelExample.php.txt')
)
);
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeTools\SettingsFileWriter;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
class SettingsFileWriterTest extends TestCase
{
private $container;
private $settingsWriter;
protected function setUp()
{
parent::setUp();
$this->container = new UpgradeContainer('/html', '/html/admin');
$this->settingsWriter = new SettingsFileWriter($this->container->getTranslator());
}
public function testSettingsIsProperlyGenerated()
{
$fileExpected = "<?php
define('_DB_SERVER_', '127.0.0.1:3307');
define('_DB_NAME_', 'prestashop16');
define('_DB_USER_', 'root');
define('_DB_PREFIX_', 'ps_');
define('_MYSQL_ENGINE_', 'InnoDB');
define('_PS_CACHING_SYSTEM_', 'CacheMemcache');
define('_PS_CACHE_ENABLED_', '0');
define('_COOKIE_KEY_', 'dedeedededede');
define('_COOKIE_IV_', 'wololo');
define('_PS_CREATION_DATE_', '2018-05-16');
define('_PS_VERSION_', '1.6.1.18');
define('_RIJNDAEL_KEY_', 'zrL1GDp2oqDoXFss');
define('_RIJNDAEL_IV_', 'QSt/I95YtA==');
";
$datas = array(
'_DB_SERVER_' => '127.0.0.1:3307',
'_DB_NAME_' => 'prestashop16',
'_DB_USER_' => 'root',
'_DB_PREFIX_' => 'ps_',
'_MYSQL_ENGINE_' => 'InnoDB',
'_PS_CACHING_SYSTEM_' => 'CacheMemcache',
'_PS_CACHE_ENABLED_' => '0',
'_COOKIE_KEY_' => 'dedeedededede',
'_COOKIE_IV_' => 'wololo',
'_PS_CREATION_DATE_' => '2018-05-16',
'_PS_VERSION_' => '1.6.1.18',
'_RIJNDAEL_KEY_' => 'zrL1GDp2oqDoXFss',
'_RIJNDAEL_IV_' => 'QSt/I95YtA==',
);
$file = tempnam(sys_get_temp_dir(), 'PSS');
$this->settingsWriter->writeSettingsFile($file, $datas);
$this->assertSame($fileExpected, file_get_contents($file));
}
}

View File

@@ -0,0 +1,93 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\State;
class StateTest extends TestCase
{
public function testClassReceivesProperty()
{
$state = new State();
$state->importFromArray(['backupName' => 'doge']);
$exported = $state->export();
$this->assertSame('doge', $state->getBackupName());
$this->assertSame('doge', $exported['backupName']);
}
public function testClassReceivesModulesAddonsProperty()
{
$modules = [
22320 => 'ps_imageslider',
22323 => 'ps_socialfollow',
];
$state = new State();
$state->importFromArray(['modules_addons' => $modules]);
$exported = $state->export();
$this->assertSame($modules, $state->getModules_addons());
$this->assertSame($modules, $exported['modules_addons']);
}
public function testClassIgnoresRandomData()
{
$state = new State();
$state->importFromArray([
'wow' => 'epic',
'backupName' => 'doge',
]);
$exported = $state->export();
$this->assertArrayNotHasKey('wow', $exported);
$this->assertSame('doge', $exported['backupName']);
}
// Tests with encoded data
public function testClassReceivesPropertyFromEncodedData()
{
$modules = [
22320 => 'ps_imageslider',
22323 => 'ps_socialfollow',
];
$data = [
'nextParams' => [
'backupName' => 'doge',
'modules_addons' => $modules,
],
];
$encodedData = base64_encode(json_encode($data));
$state = new State();
$state->importFromEncodedData($encodedData);
$exported = $state->export();
$this->assertSame('doge', $state->getBackupName());
$this->assertSame('doge', $exported['backupName']);
$this->assertSame($modules, $state->getModules_addons());
$this->assertSame($modules, $exported['modules_addons']);
}
}

View File

@@ -0,0 +1,53 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\Log\Logger;
use PrestaShop\Module\AutoUpgrade\Log\StreamedLogger;
class StreamedLoggerTest extends TestCase
{
/**
* @dataProvider filtersProvider
*/
public function testFiltersProperlyApplied($level, $filterLevel, $expected)
{
$logger = new StreamedLogger();
$logger->setFilter($filterLevel);
$this->assertSame($expected, $logger->isFiltered($level));
}
public function filtersProvider()
{
return array(
array(Logger::EMERGENCY, Logger::INFO, false),
array(Logger::INFO, Logger::EMERGENCY, true),
array(Logger::ERROR, Logger::ERROR, false),
array(Logger::ERROR, Logger::WARNING, false),
array(Logger::ERROR, Logger::CRITICAL, true),
);
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeTools\Translator;
/**
* Test for backward compatibility translation feature.
*/
class TranslatorTest extends TestCase
{
protected $translator;
protected function setUp()
{
parent::setUp();
$this->translator = new Translator(__CLASS__);
}
/**
* @dataProvider translationsTestCaseProvider
*/
public function testTranslationWithoutParams($origin, $parameters, $expected)
{
$this->assertSame($expected, $this->translator->applyParameters($origin, $parameters));
}
public function translationsTestCaseProvider()
{
return array(
// Test with %s in translated text
array(
'Downloaded archive will come from %s',
array('https://download.prestashop.com/download/releases/prestashop_1.7.3.0.zip'),
'Downloaded archive will come from https://download.prestashop.com/download/releases/prestashop_1.7.3.0.zip',
),
// Text without parameter
array(
'Using class ZipArchive...',
array(),
'Using class ZipArchive...',
),
// Text with placeholders
array(
'[TRANSLATION] The translation files have not been merged into file %filename%. Switch to copy %filename%.',
array('%filename%' => 'doge.txt'),
'[TRANSLATION] The translation files have not been merged into file doge.txt. Switch to copy doge.txt.',
),
);
}
}

View File

@@ -0,0 +1,68 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\Parameters\FileConfigurationStorage;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfigurationStorage;
class UpgradeConfigurationTest extends TestCase
{
/**
* This method only initialize the configuration from empty data saves.
* We expect to find all the default data.
*/
public function testDefaultValuesAreSet()
{
$filePath = sys_get_temp_dir();
$fileName = __FUNCTION__ . '.dat';
$upgradeConfigurationStorage = new UpgradeConfigurationStorage($filePath . DIRECTORY_SEPARATOR);
$upgradeConfiguration = $upgradeConfigurationStorage->load($fileName);
foreach ($upgradeConfigurationStorage->getDefaultData() as $key => $value) {
$this->assertSame($value, $upgradeConfiguration->get($key));
}
}
/**
* In case the data save contains some values, we still expect to find the dault data
* to be defined, even if they can't be found in the saved file.
*/
public function testDefaultValuesAreSetWhenNotExistingInSavedFile()
{
$filePath = sys_get_temp_dir();
$fileName = __FUNCTION__ . '.dat';
(new FileConfigurationStorage($filePath . DIRECTORY_SEPARATOR))->save(['randomData' => 'trololo'], $fileName);
$upgradeConfigurationStorage = new UpgradeConfigurationStorage($filePath . DIRECTORY_SEPARATOR);
$upgradeConfiguration = $upgradeConfigurationStorage->load($fileName);
foreach ($upgradeConfigurationStorage->getDefaultData() as $key => $value) {
$this->assertSame($value, $upgradeConfiguration->get($key));
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
class UpgradeContainerTest extends TestCase
{
public function testSameResultFormAdminSubDir()
{
$container = new UpgradeContainer(__DIR__, __DIR__ . '/..');
$this->assertNotSame($container->getProperty(UpgradeContainer::PS_ADMIN_SUBDIR), str_replace($container->getProperty(UpgradeContainer::PS_ROOT_PATH), '', $container->getProperty(UpgradeContainer::PS_ADMIN_PATH)));
}
/**
* @dataProvider objectsToInstanciateProvider
*/
public function testObjectInstanciation($functionName, $expectedClass)
{
$container = $this->getMockBuilder(UpgradeContainer::class)
->setConstructorArgs(array(__DIR__, __DIR__ . '/..'))
->setMethods(array('getDb'))
->getMock();
$actualClass = get_class(call_user_func(array($container, $functionName)));
$this->assertSame($actualClass, $expectedClass);
}
public function objectsToInstanciateProvider()
{
// | Function to call | Expected class |
return array(
array('getCacheCleaner', PrestaShop\Module\AutoUpgrade\UpgradeTools\CacheCleaner::class),
array('getCookie', PrestaShop\Module\AutoUpgrade\Cookie::class),
array('getFileConfigurationStorage', PrestaShop\Module\AutoUpgrade\Parameters\FileConfigurationStorage::class),
array('getFileFilter', \PrestaShop\Module\AutoUpgrade\UpgradeTools\FileFilter::class),
// array('getUpgrader', \PrestaShop\Module\AutoUpgrade\Upgrader::class),
array('getFilesystemAdapter', PrestaShop\Module\AutoUpgrade\UpgradeTools\FilesystemAdapter::class),
array('getLogger', PrestaShop\Module\AutoUpgrade\Log\LegacyLogger::class),
array('getModuleAdapter', PrestaShop\Module\AutoUpgrade\UpgradeTools\ModuleAdapter::class),
array('getState', \PrestaShop\Module\AutoUpgrade\State::class),
array('getSymfonyAdapter', PrestaShop\Module\AutoUpgrade\UpgradeTools\SymfonyAdapter::class),
array('getTranslationAdapter', \PrestaShop\Module\AutoUpgrade\UpgradeTools\Translation::class),
array('getTranslator', \PrestaShop\Module\AutoUpgrade\UpgradeTools\Translator::class),
array('getTwig', Twig_Environment::class),
array('getPrestaShopConfiguration', PrestaShop\Module\AutoUpgrade\PrestashopConfiguration::class),
array('getUpgradeConfiguration', PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration::class),
array('getWorkspace', PrestaShop\Module\AutoUpgrade\Workspace::class),
array('getZipAction', PrestaShop\Module\AutoUpgrade\ZipAction::class),
);
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*
* 2007-2019 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
class ZipActionTest extends TestCase
{
const ZIP_CONTENT_PATH = __DIR__ . '/fixtures/ArchiveExample.zip';
private $container;
private $contentExcepted;
protected function setUp()
{
$this->contentExcepted = [
'dummyFolder/',
'dummyFolder/AppKernelExample.php.txt',
];
$this->container = new UpgradeContainer(__DIR__, __DIR__ . '/..');
}
public function testArchiveContentWithZipArchive()
{
$zipAction = $this->container->getZipAction();
$this->assertSame($this->contentExcepted, $zipAction->listContent(self::ZIP_CONTENT_PATH));
}
public function testCreateArchiveWithZipArchive()
{
$newZipPath = tempnam(sys_get_temp_dir(), 'mod');
$zipAction = $this->container->getZipAction();
$files = [__FILE__];
$this->assertSame(true, $zipAction->compress($files, $newZipPath));
// Cleanup
unlink($newZipPath);
}
public function testExtractArchiveWithZipArchive()
{
// Get tmp folder
$destinationFolder = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid();
$zipAction = $this->container->getZipAction();
$this->assertSame(true, $zipAction->extract(self::ZIP_CONTENT_PATH, $destinationFolder));
// We check the files were actually extracted
foreach ($this->contentExcepted as $file) {
$completePath = $destinationFolder . DIRECTORY_SEPARATOR . $file;
$this->assertTrue(
is_dir($completePath) || (file_exists($completePath) && filesize($completePath)),
"$completePath does not exist"
);
}
}
}

View File

@@ -0,0 +1,84 @@
version: '3'
services:
tests:
build: E2E/
environment:
SELENIUM_HOST: selenium-chrome
URL: prestashop-web
depends_on:
- 'prestashop'
- 'selenium-chrome'
command:
[
'/tmp/wait-for-it.sh',
'--timeout=200',
'--strict',
'prestashop:80',
'--',
'/tmp/node_modules/mocha/bin/mocha /tmp/test/campaigns/high/13_installation',
'--URL=prestashop-web',
'--SELENIUM=selenium-chrome',
'--DIR=/home/seluser/Downloads/',
'--DB_SERVER=db',
'--DB_USER=root',
'--DB_PASSWD=admin',
'--RCTARGET=/tmp/',
'--RCLINK=http://localhost/prestashop_1.7.3.0-RC1.zip',
]
volumes:
- ./screenshots/:/home/test/screenshots/
- downloads:/home/seluser/Downloads
networks:
- default
prestashop:
build: E2E/docker_prestashop/
environment:
DB_SERVER: db
PS_INSTALL_AUTO: 0
PS_COUNTRY: fr
PS_DOMAIN: prestashop-web
PS_FOLDER_ADMIN: admin-dev
PS_FOLDER_INSTALL: install-dev
depends_on:
- 'db'
command:
[
'/tmp/wait-for-it.sh',
'--timeout=60',
'--strict',
'db:3306',
'--',
'/tmp/docker_run.sh',
]
ports:
- 8002:80
networks:
default:
aliases:
- prestashop-web
selenium-chrome:
image: selenium/standalone-chrome
ports:
- 4444:4444
volumes:
- downloads:/home/seluser/Downloads
networks:
default:
aliases:
- selenium-chrome
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: admin
networks:
- default
volumes:
downloads:
networks:
default:

View File

@@ -0,0 +1,244 @@
<?php
/**
* 2007-2018 PrestaShop
*
* 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.txt.
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use Doctrine\DBAL\DriverManager;
use PrestaShopBundle\Kernel\ModuleRepository;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
const VERSION = '1.7.6.0';
const MAJOR_VERSION_STRING = '1.7';
const MAJOR_VERSION = 17;
const MINOR_VERSION = 6;
const RELEASE_VERSION = 0;
/**
* @{inheritdoc}
*/
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
// PrestaShop Core bundle
new PrestaShopBundle\PrestaShopBundle(),
// PrestaShop Translation parser
new PrestaShop\TranslationToolsBundle\TranslationToolsBundle(),
// REST API consumer
new Csa\Bundle\GuzzleBundle\CsaGuzzleBundle(),
new League\Tactician\Bundle\TacticianBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
}
if ('dev' === $this->getEnvironment()) {
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
}
/* Will not work until PrestaShop is installed */
if ($this->parametersFileExists()) {
try {
$this->enableComposerAutoloaderOnModules($this->getActiveModules());
} catch (\Exception $e) {
}
}
return $bundles;
}
/**
* @{inheritdoc}
*/
protected function getKernelParameters()
{
$kernelParameters = parent::getKernelParameters();
$activeModules = array();
/* Will not work until PrestaShop is installed */
if ($this->parametersFileExists()) {
try {
$this->getConnection()->connect();
$activeModules = $this->getActiveModules();
} catch (\Exception $e) {
}
}
return array_merge(
$kernelParameters,
array('kernel.active_modules' => $activeModules)
);
}
/**
* @{inheritdoc}
*/
public function getRootDir()
{
return __DIR__;
}
/**
* @{inheritdoc}
*/
public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}
/**
* @{inheritdoc}
*/
public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}
/**
* @{inheritdoc}
* @throws \Exception
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container) {
$container->setParameter('container.autowiring.strict_mode', true);
$container->setParameter('container.dumper.inline_class_loader', false);
$container->addObjectResource($this);
});
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
/**
* Return all active modules.
*
* @return array list of modules names.
* @throws \Doctrine\DBAL\DBALException
*/
private function getActiveModules()
{
$databasePrefix = $this->getParameters()['database_prefix'];
$modulesRepository = new ModuleRepository(
$this->getConnection(),
$databasePrefix
);
return $modulesRepository->getActiveModules();
}
/**
* @return array The root parameters of PrestaShop.
*/
private function getParameters()
{
if ($this->parametersFileExists()) {
$config = require $this->getParametersFile();
return $config['parameters'];
}
return array();
}
/**
* @var bool
* @return bool
*/
private function parametersFileExists()
{
return file_exists($this->getParametersFile());
}
/**
* @return string file path to PrestaShop configuration parameters.
*/
private function getParametersFile()
{
return $this->getRootDir().'/config/parameters.php';
}
/**
* @return \Doctrine\DBAL\Connection
* @throws \Doctrine\DBAL\DBALException
*/
private function getConnection()
{
$parameters = $this->getParameters();
return DriverManager::getConnection(array(
'dbname' => $parameters['database_name'],
'user' => $parameters['database_user'],
'password' => $parameters['database_password'],
'host' => $parameters['database_host'],
'port' => $parameters['database_port'],
'charset' => 'utf8',
'driver' => 'pdo_mysql',
));
}
/**
* Enable auto loading of module Composer autoloader if needed.
* Need to be done as earlier as possible in application lifecycle.
*
* @param array $modules the list of modules
*/
private function enableComposerAutoloaderOnModules($modules)
{
foreach ($modules as $module) {
$autoloader = __DIR__.'/../modules/'.$module.'/vendor/autoload.php';
if (file_exists($autoloader)) {
include_once $autoloader;
}
}
}
/**
* Gets the application root dir.
* Override Kernel due to the fact that we remove the composer.json in
* downloaded package. More we are not a framework and the root directory
* should always be the parent of this file.
*
* @return string The project root dir
*/
public function getProjectDir()
{
return realpath(__DIR__ . '/..');
}
}

Binary file not shown.

View File

@@ -0,0 +1,3 @@
FROM phpstan/phpstan:latest
RUN apk --update --progress --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.7/community add \
php7-zip

View File

@@ -0,0 +1,68 @@
<?php
$rootDir = getenv('_PS_ROOT_DIR_');
if (!$rootDir) {
echo '[ERROR] Define _PS_ROOT_DIR_ with the path to PrestaShop folder' . PHP_EOL;
exit(1);
}
// Add module composer autoloader
require_once dirname(__DIR__) . '/../vendor/autoload.php';
// Add PrestaShop composer autoload
define('_PS_ADMIN_DIR_', $rootDir . '/admin-dev/');
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
require_once $rootDir . '/config/defines.inc.php';
require_once $rootDir . '/config/autoload.php';
require_once $rootDir . '/config/bootstrap.php';
// Lib existing on PS 1.6
if (file_exists(_PS_TOOL_DIR_ . 'tar/Archive_Tar.php')) {
require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
}
// Make sure loader php-parser is coming from php stan composer
$loader = new \Composer\Autoload\ClassLoader();
$loader->setPsr4('PhpParser\\', array('/composer/vendor/nikic/php-parser/lib/PhpParser'));
$loader->register(true);
// We must declare these constant in this boostrap script.
// Ignoring the error partern with this value will throw another error if not found
// during the checks.
$constantsToDefine = [
'_DB_SERVER_',
'_DB_NAME_',
'_DB_USER_',
'_DB_PASSWD_',
'_MYSQL_ENGINE_',
'_COOKIE_KEY_',
'_COOKIE_IV_',
'_PS_VERSION_',
'_DB_PREFIX_',
'_PS_SSL_PORT_',
'_THEME_NAME_',
'_PARENT_THEME_NAME_',
'__PS_BASE_URI__',
'_PS_PRICE_DISPLAY_PRECISION_',
'_PS_PRICE_COMPUTE_PRECISION_',
'_PS_OS_CHEQUE_',
'_PS_OS_PAYMENT_',
'_PS_OS_PREPARATION_',
'_PS_OS_SHIPPING_',
'_PS_OS_DELIVERED_',
'_PS_OS_CANCELED_',
'_PS_OS_REFUND_',
'_PS_OS_ERROR_',
'_PS_OS_OUTOFSTOCK_',
'_PS_OS_OUTOFSTOCK_PAID_',
'_PS_OS_OUTOFSTOCK_UNPAID_',
'_PS_OS_BANKWIRE_',
'_PS_OS_PAYPAL_',
'_PS_OS_WS_PAYMENT_',
'_PS_OS_COD_VALIDATION_',
];
foreach ($constantsToDefine as $constant) {
if (!defined($constant)) {
define($constant, 'DUMMY_VALUE');
}
}

View File

@@ -0,0 +1,33 @@
#################################################################################
# This file is a copy of phpstan.neon with additional rules for PS 1.6
# Its objective is to avoid false-positive results regarding non-existing classes
#################################################################################
parameters:
bootstrap: /web/module/tests/phpstan/bootstrap.php
reportUnmatchedIgnoredErrors: false
paths:
- /web/module/classes
excludes_analyse:
- /web/module/classes/Tools14.php
- /web/module/classes/pclzip.lib.php
- /web/module/functions.php
- /web/module/classes/UpgradeTools/CoreUpgrader/CoreUpgrader17.php
- /web/module/classes/UpgradeTools/SymfonyAdapter.php
ignoreErrors:
# module specific
- '#Function deactivate_custom_modules not found.#'
- '#Constant MCRYPT_[A-Z0-9_]+ not found.#'
- "#Call to function method_exists#"
# CLDR related check
- '#[cC]lass PrestaShop\\PrestaShop\\Core\\Cldr\\Update#'
# AppKernel wasn't properly listed in autoloader
- '#AppKernel#'
# Below are messages ignored on PS 1.6
- '#[cC]lass PrestaShop\\PrestaShop\\Core\\Addon\\Theme\\ThemeManagerBuilder#'
- '#PrestaShop\\Module\\AutoUpgrade\\UpgradeTools\\ModuleAdapter#'
- '#PrestaShop\\PrestaShop\\Adapter\\Module\\ModuleDataUpdater#'
- '#PrestaShopBundle\\Install\\Upgrade#'
- '#Call to an undefined static method ConfigurationTest::test_curl().#'
level: 5

View File

@@ -0,0 +1,20 @@
parameters:
bootstrap: /web/module/tests/phpstan/bootstrap.php
reportUnmatchedIgnoredErrors: false
paths:
- /web/module/classes
excludes_analyse:
- /web/module/classes/Tools14.php
- /web/module/classes/pclzip.lib.php
- /web/module/functions.php
ignoreErrors:
# module specific
- '#Function deactivate_custom_modules not found.#'
- '#Constant MCRYPT_[A-Z0-9_]+ not found.#'
- "#Call to function method_exists#"
# CLDR related check
- '#[cC]lass PrestaShop\\PrestaShop\\Core\\Cldr\\Update#'
# AppKernel wasn't properly listed in autoloader
- '#AppKernel#'
level: 5

View File

@@ -0,0 +1,20 @@
#!/bin/bash
if [[ -z "${TRAVIS_BUILD_DIR}" ]]; then
echo "Variable TRAVIS_BUILD_DIR must defined as the root of your autoupgrade project!"
echo "Example: export TRAVIS_BUILD_DIR=$(realpath $(dirname "$0")/..)"
exit 1
fi
BRANCH=mbadrani-develop
FOLDER=tests/E2E
cd $TRAVIS_BUILD_DIR
if [ ! -d "$FOLDER" ]; then
echo "$FOLDER does not exist, cloning tests..."
git clone --depth=10 --branch=$BRANCH https://github.com/Quetzacoalt91/PrestaShop.git $FOLDER
cd $FOLDER
git filter-branch --prune-empty --subdirectory-filter tests/E2E $BRANCH
fi
docker-compose up

View File

@@ -0,0 +1,70 @@
<?php
/*
* 2007-2018 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* 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 license@prestashop.com 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
// Although no arguments execute the script, you can get some help if requested.
if (isset($argv) && is_array($argv) && in_array('--help', $argv)) {
displayHelp();
exit(0);
}
array_shift($argv);
$command = implode(' ', $argv);
$result = 0;
while (!empty($command) && !$result) {
$lastLine = system('php ' . $command . ' 2>&1', $result);
// if we require to run another command, it will detected here
$pos = strpos($lastLine, $argv[0]);
$command = ($pos === false ? null : substr($lastLine, $pos));
}
exit($result);
/**
* displays the help.
*/
function displayHelp()
{
echo <<<EOF
PrestaShop upgrade/rollback test
This script can be called to complete a whole process of your shop. This script is currently stored in tests/ as it
is used by automated tests.
testCliProcess.php <Path to cli-upgrade.php/cli-rollback.php etc.> [Options]
------------------
Options
--help Display this message.
--dir Tells where the admin directory is.
[UPGRADE]
--channel Selects what upgrade to run (minor, major etc.)
[ROLLBACK]
--backup Select the backup to restore. To be found in autoupgrade/backup, in your admin folder.
EOF;
}