Skip to content

Commit

Permalink
Enable PHP CS Fixer on tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
matks committed Jan 8, 2019
1 parent db7fc69 commit 9684199
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 37 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $finder = PhpCsFixer\Finder::create()->in([
__DIR__.'/src',
__DIR__.'/classes',
__DIR__.'/controllers',
__DIR__.'/tests',
]);

return PhpCsFixer\Config::create()
Expand Down
17 changes: 8 additions & 9 deletions tests/E2E/prepare-shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

define('_PS_MODE_DEV_', false);
require __DIR__.'/../../config/config.inc.php';
require __DIR__ . '/../../config/config.inc.php';

// useful variables

$language = Context::getContext()->language;
$shop = Context::getContext()->shop;
$dbPrefix = _DB_PREFIX_;
$language = Context::getContext()->language;
$shop = Context::getContext()->shop;
$dbPrefix = _DB_PREFIX_;

// Enable URL rewriting

Expand Down Expand Up @@ -94,9 +93,9 @@ function disableModule($moduleName)

function hookModule($moduleName, $hookName)
{
$dbPrefix = _DB_PREFIX_;
$module = Module::getInstanceByName($moduleName);
$moduleId = $module->id;
$dbPrefix = _DB_PREFIX_;
$module = Module::getInstanceByName($moduleName);
$moduleId = $module->id;
Db::getInstance()->execute(
"DELETE FROM {$dbPrefix}hook_module WHERE id_module=$moduleId"
);
Expand Down Expand Up @@ -135,7 +134,7 @@ function hookModule($moduleName, $hookName)
Language::checkAndAddLanguage('fr');
echo "- added French language just so that we have 2\n";
$languages = Language::getLanguages();
echo " Number of languages : ".count($languages)."\n";
echo ' Number of languages : ' . count($languages) . "\n";

$order = new Order(5);
$history = new OrderHistory();
Expand Down
17 changes: 8 additions & 9 deletions tests/Selenium/prepare-shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

define('_PS_MODE_DEV_', false);
require __DIR__.'/../../config/config.inc.php';
require __DIR__ . '/../../config/config.inc.php';

// useful variables

$language = Context::getContext()->language;
$shop = Context::getContext()->shop;
$dbPrefix = _DB_PREFIX_;
$language = Context::getContext()->language;
$shop = Context::getContext()->shop;
$dbPrefix = _DB_PREFIX_;

// Enable URL rewriting

Expand Down Expand Up @@ -94,9 +93,9 @@ function disableModule($moduleName)

function hookModule($moduleName, $hookName)
{
$dbPrefix = _DB_PREFIX_;
$module = Module::getInstanceByName($moduleName);
$moduleId = $module->id;
$dbPrefix = _DB_PREFIX_;
$module = Module::getInstanceByName($moduleName);
$moduleId = $module->id;
Db::getInstance()->execute(
"DELETE FROM {$dbPrefix}hook_module WHERE id_module=$moduleId"
);
Expand Down Expand Up @@ -137,7 +136,7 @@ function hookModule($moduleName, $hookName)
Language::checkAndAddLanguage('fr');
echo "- added French language just so that we have 2\n";
$languages = Language::getLanguages();
echo " Number of languages : ".count($languages)."\n";
echo ' Number of languages : ' . count($languages) . "\n";

$order = new Order(5);
$history = new OrderHistory();
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/ErrorsDataListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class ErrorsDataListener extends BaseTestListener
{
/**
* @var PhpErrorsCounter a dedicated error handler.
* @var PhpErrorsCounter a dedicated error handler
*/
private $errorsCounter;

Expand All @@ -56,7 +56,7 @@ public function __construct()

public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$this->suites++;
++$this->suites;
if (!$this->isRegistered) {
$this->errorsCounter->registerErrorHandler();
$this->isRegistered = true;
Expand All @@ -65,12 +65,12 @@ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)

public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$this->suites--;
--$this->suites;

if ($this->suites === 0) {
printf(PHP_EOL . PHP_EOL . 'Current report of phpErrorsHandler:');
printf(PHP_EOL . $this->errorsCounter->displaySummary() . PHP_EOL);
$this->errorsCounter->restoreErrorHandler();
}
}
}
}
4 changes: 2 additions & 2 deletions tests/TestCase/PhpErrorsCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PhpErrorsCounter
public function registerErrorHandler()
{
set_error_handler(function ($errorType) {
switch($errorType) {
switch ($errorType) {
case E_WARNING:
$this->warnings++;
break;
Expand Down Expand Up @@ -99,7 +99,7 @@ public function getErrors()
}

/**
* @return string a summary report of errors.
* @return string a summary report of errors
*/
public function displaySummary()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace Tests\Unit\Core\Form\IdentifiableObject\DataProvider;

use DateTime;
use PHPUnit\Framework\TestCase;
use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface;
use PrestaShop\PrestaShop\Core\ConfigurationInterface;
Expand Down Expand Up @@ -98,7 +97,7 @@ public function setUp()
$this->returnValueMap([
[
'PS_CUSTOMER_GROUP', 3,
]
],
])
)
;
Expand Down
7 changes: 3 additions & 4 deletions tests/Unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

define('_PS_IN_TEST_', true);
define('_PS_ROOT_DIR_', __DIR__ . '/../..');
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_.'/tests-legacy/resources/modules/');
require_once dirname(__FILE__).'/../../config/defines.inc.php';
require_once _PS_CONFIG_DIR_.'autoload.php';
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/tests-legacy/resources/modules/');
require_once dirname(__FILE__) . '/../../config/defines.inc.php';
require_once _PS_CONFIG_DIR_ . 'autoload.php';

if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/../../vendor/autoload.php');
Expand Down
13 changes: 6 additions & 7 deletions tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
header('Location: ../');
exit;

0 comments on commit 9684199

Please sign in to comment.