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
Showing
11 changed files
with
112 additions
and
62 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
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 |
---|---|---|
|
@@ -302,7 +302,7 @@ public function installDatabase($clear_database = false) | |
*/ | ||
public function generateSf2ProductionEnv() | ||
{ | ||
$schemaUpgrade = new UpgradeDatabase(defined('_PS_IN_TEST_')?'test':null); | ||
$schemaUpgrade = new UpgradeDatabase(defined('_PS_IN_TEST_') ? 'test' : null); | ||
$schemaUpgrade->addDoctrineSchemaUpdate(); | ||
$output = $schemaUpgrade->execute(); | ||
|
||
|
@@ -356,6 +356,9 @@ public function installCldrDatas() | |
} | ||
} | ||
|
||
/** | ||
* Initialize the prestashop context with default values during tests | ||
*/ | ||
public function initializeTestContext() | ||
{ | ||
$smarty = null; | ||
|
@@ -403,49 +406,6 @@ public function initializeTestContext() | |
$context->smarty = $smarty; | ||
} | ||
|
||
public static function createTestDB() { | ||
define('_PS_IN_TEST_', true); | ||
define('__PS_BASE_URI__', '/'); | ||
define('_PS_ROOT_DIR_', __DIR__ . '/../../..'); | ||
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_.'/tests/resources/modules/'); | ||
require_once(__DIR__.'/../../../install-dev/init.php'); | ||
|
||
$install = new Install(); | ||
\DbPDOCore::createDatabase(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_, false); | ||
$install->clearDatabase(); | ||
$install->installDatabase(); | ||
$install->initializeTestContext(); | ||
$install->installDefaultData('test_shop', false, false, true); | ||
$install->populateDatabase(); | ||
$install->installCldrDatas(); | ||
|
||
$install->configureShop(array( | ||
'admin_firstname' => 'puff', | ||
'admin_lastname' => 'daddy', | ||
'admin_password' => 'test', | ||
'admin_email' => '[email protected]', | ||
'configuration_agrement' => true, | ||
'send_informations' => false, | ||
)); | ||
$install->installFixtures(); | ||
$install->installTheme(); | ||
$language = new \Language(1); | ||
Context::getContext()->language = $language; | ||
$install->installModules(); | ||
$install->installModulesAddons(); | ||
|
||
DatabaseDump::create(); | ||
} | ||
|
||
public static function restoreTestDB() | ||
{ | ||
if (!file_exists(sys_get_temp_dir().'/'.'ps_dump.sql')) { | ||
throw new DBALException('You need to run \'composer create-test-db\' to create the initial test database'); | ||
} | ||
|
||
DatabaseDump::restoreDb(); | ||
} | ||
|
||
/** | ||
* PROCESS : installDefaultData | ||
* Create default shop and languages | ||
|
@@ -476,7 +436,7 @@ public function installDefaultData($shop_name, $iso_country = false, $all_langua | |
} | ||
} | ||
} | ||
$iso_codes_to_install = array_flip(array_flip($iso_codes_to_install)); | ||
$iso_codes_to_install = array_unique($iso_codes_to_install); | ||
} else { | ||
$iso_codes_to_install = null; | ||
} | ||
|
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,86 @@ | ||
<?php | ||
/** | ||
* 2007-2017 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 [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 http://www.prestashop.com for more information. | ||
* | ||
* @author PrestaShop SA <[email protected]> | ||
* @copyright 2007-2017 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA | ||
*/ | ||
|
||
namespace PrestaShopBundle\Tests\Utils; | ||
|
||
use Doctrine\DBAL\DBALException; | ||
use PrestaShopBundle\Install\DatabaseDump; | ||
use PrestaShopBundle\Install\Install; | ||
|
||
class Database | ||
{ | ||
/** | ||
* Create the initialize database used for test | ||
*/ | ||
public static function createTestDB() | ||
{ | ||
define('_PS_IN_TEST_', true); | ||
define('__PS_BASE_URI__', '/'); | ||
define('_PS_ROOT_DIR_', __DIR__ . '/../../../../'); | ||
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/tests/resources/modules/'); | ||
require_once(__DIR__ . '/../../../../install-dev/init.php'); | ||
|
||
$install = new Install(); | ||
\DbPDOCore::createDatabase(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_, false); | ||
$install->clearDatabase(); | ||
$install->installDatabase(); | ||
$install->initializeTestContext(); | ||
$install->installDefaultData('test_shop', false, false, true); | ||
$install->populateDatabase(); | ||
$install->installCldrDatas(); | ||
|
||
$install->configureShop(array( | ||
'admin_firstname' => 'puff', | ||
'admin_lastname' => 'daddy', | ||
'admin_password' => 'test', | ||
'admin_email' => '[email protected]', | ||
'configuration_agrement' => true, | ||
'send_informations' => false, | ||
)); | ||
$install->installFixtures(); | ||
$install->installTheme(); | ||
$language = new \Language(1); | ||
\Context::getContext()->language = $language; | ||
$install->installModules(); | ||
$install->installModulesAddons(); | ||
|
||
DatabaseDump::create(); | ||
} | ||
|
||
/** | ||
* Restore the test database in its initial state from a dump generated during createTestDB | ||
* | ||
* @throws DBALException | ||
*/ | ||
public static function restoreTestDB() | ||
{ | ||
if (!file_exists(sys_get_temp_dir() . '/' . 'ps_dump.sql')) { | ||
throw new DBALException('You need to run \'composer create-test-db\' to create the initial test database'); | ||
} | ||
|
||
DatabaseDump::restoreDb(); | ||
} | ||
} |
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
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