Skip to content

Commit 0b68f1b

Browse files
sreichelkiatng
andauthored
PHPUnit: added some tests (OpenMage#4204)
* Rector: CQ - UnusedForeachValueToArrayKeysRector (#1) * Rector: CQ - UnusedForeachValueToArrayKeysRector See Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector * fixes + phpstan See fix at rector: rectorphp/rector-src#6164 * Updated test * Added test * Added test * Renamed and updated test * Updated test * Updated test * Updated test * Updated test * Revert "Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)" This reverts commit 3d7eaf6. * Updated test (phpstan L9) * Updated test (fixed namespace) * Updated test (phpstan L9) * Added unit test to code style check and phpstan * Some cleanup * Some cleanup * Some cleanup * Updated workflow * ddev shortcut [ski ci] * Moved phphunit config file * Merged phpunit & sonar workflow * PhpUnit fix - PHP Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/runner/work/magento-lts/magento-lts/lib/Varien/Object.php on line 594 * Fix linefeed (?) * Fix config * Fixed invalid php version * Use minimum version * Use minimum version for SonarScan * Fix command [ski ci] * Enable xdebug * Added test, ref OpenMage#4123 * Revert "Some cleanup" This reverts commit 6d45ed6. * Revert "PhpUnit fix" This reverts commit f4935f1. * Updated test * Updated docblocks * Revert "Fix linefeed (?)" This reverts commit dee0422. * Added tests * Added tests * Added tests [skip ci] * Reverted changes to Mage_Core_Model_Website * Updated config * Updated .gitignore * Updated workflow * Updated workflow typo * Updated workflow continue on error * Updated workflow if condition * Updated workflow [skip ci] * Moved tests to root (as common) * Fixed paths * Fixed paths * Fixed paths * CS fix * Added test * Added test * Added groups/suites * Updated test * CS fix * Updated .gitignore * Updated phpunit.xml.dist * Added test * Added tests * Added tests * Added tests * Added tests * CS fix * CS fix * Added tests * Added tests * Added tests * Added tests * CS/PhpStan fixes * Update - some tests commented - need files changes * Nicer output? * Don't wait for phpcs * Revert output * Updated workflows * Added test * Added phpunit command to composer.json * Updated DDEV commands * Fixed phpunit commands at composer.json * WIP * phpcs and phpstan fixes * Updated tests * Moved test to correct directory * Added tests --------- Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent 93856f0 commit 0b68f1b

File tree

44 files changed

+1150
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1150
-71
lines changed

app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,11 @@ public function getDeleteButtonHtml()
110110
*/
111111
public function initForm()
112112
{
113-
/** @var Mage_Customer_Model_Customer $customer */
114-
$customer = Mage::registry('current_customer');
115-
116113
$form = new Varien_Data_Form();
117114
$fieldset = $form->addFieldset('address_fieldset', [
118115
'legend' => Mage::helper('customer')->__("Edit Customer's Address")]);
119116

117+
$customer = $this->getRegistryCurrentCustomer();
120118
$addressModel = Mage::getModel('customer/address');
121119
$addressModel->setCountryId(Mage::helper('core')->getDefaultCountry($customer->getStore()));
122120
/** @var Mage_Customer_Model_Form $addressForm */
@@ -296,4 +294,9 @@ public function addValuesToNameSuffixElement($values)
296294
}
297295
return $this;
298296
}
297+
298+
protected function getRegistryCurrentCustomer(): ?Mage_Customer_Model_Customer
299+
{
300+
return Mage::registry('current_customer');
301+
}
299302
}

app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function initForm()
3131
{
3232
$form = new Varien_Data_Form();
3333
$form->setHtmlIdPrefix('_newsletter');
34-
$customer = Mage::registry('current_customer');
34+
$customer = $this->getRegistryCurrentCustomer();
3535
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
3636
Mage::register('subscriber', $subscriber);
3737

@@ -95,4 +95,9 @@ protected function _prepareLayout()
9595
);
9696
return parent::_prepareLayout();
9797
}
98+
99+
protected function getRegistryCurrentCustomer(): ?Mage_Customer_Model_Customer
100+
{
101+
return Mage::registry('current_customer');
102+
}
98103
}

app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function initForm()
2929
$form = new Varien_Data_Form();
3030
$form->setHtmlIdPrefix('_view');
3131

32-
$model = Mage::registry('current_convert_profile');
32+
$model = $this->getRegistryCurrentConvertProfile();
3333

3434
$fieldset = $form->addFieldset('base_fieldset', [
3535
'legend' => Mage::helper('adminhtml')->__('View Actions XML'),
@@ -50,4 +50,9 @@ public function initForm()
5050

5151
return $this;
5252
}
53+
54+
protected function getRegistryCurrentConvertProfile(): ?Mage_Dataflow_Model_Profile
55+
{
56+
return Mage::registry('current_convert_profile');
57+
}
5358
}

app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function initForm()
2929
$form = new Varien_Data_Form();
3030
$form->setHtmlIdPrefix('_edit');
3131

32-
$model = Mage::registry('current_convert_profile');
32+
$model = $this->getRegistryCurrentConvertProfile();
3333

3434
$fieldset = $form->addFieldset('base_fieldset', [
3535
'legend' => Mage::helper('adminhtml')->__('General Information'),
@@ -57,4 +57,9 @@ public function initForm()
5757

5858
return $this;
5959
}
60+
61+
protected function getRegistryCurrentConvertProfile(): ?Mage_Dataflow_Model_Profile
62+
{
63+
return Mage::registry('current_convert_profile');
64+
}
6065
}

app/code/core/Mage/Cms/Controller/Router.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function match(Zend_Controller_Request_Http $request)
4545
Mage::app()->getFrontController()->getResponse()
4646
->setRedirect(Mage::getUrl('install'))
4747
->sendResponse();
48+
// phpcs:ignore: Ecg.Security.LanguageConstruct.ExitUsage
4849
exit;
4950
}
5051

app/code/core/Mage/Cms/Helper/Page.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pag
5151
{
5252
$page = Mage::getSingleton('cms/page');
5353
if (!is_null($pageId) && $pageId !== $page->getId()) {
54-
$delimeterPosition = strrpos($pageId, '|');
55-
if ($delimeterPosition) {
56-
$pageId = substr($pageId, 0, $delimeterPosition);
54+
$delimiterPosition = strrpos($pageId, '|');
55+
if ($delimiterPosition) {
56+
$pageId = substr($pageId, 0, $delimiterPosition);
5757
}
5858

5959
$page->setStoreId(Mage::app()->getStore()->getId());

app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function getStorageRoot()
7070
if (!$this->_storageRoot) {
7171
$path = Mage::getConfig()->getOptions()->getMediaDir()
7272
. DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY;
73+
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
7374
$this->_storageRoot = realpath($path);
7475
if (!$this->_storageRoot) {
7576
$this->_storageRoot = $path;
@@ -107,6 +108,7 @@ public function getTreeNodeName()
107108
*/
108109
public function convertPathToId($path)
109110
{
111+
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
110112
$storageRoot = realpath($this->getStorageRoot());
111113
$path = str_replace($storageRoot, '', $path);
112114
return $this->idEncode($path);
@@ -121,6 +123,7 @@ public function convertPathToId($path)
121123
public function convertIdToPath($id)
122124
{
123125
$path = $this->idDecode($id);
126+
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
124127
$storageRoot = realpath($this->getStorageRoot());
125128
if (!strstr($path, $storageRoot)) {
126129
$path = $storageRoot . DS . $path;
@@ -209,7 +212,9 @@ public function getCurrentPath()
209212
$currentPath = $this->getStorageRoot();
210213
$node = $this->_getRequest()->getParam($this->getTreeNodeName());
211214
if ($node) {
215+
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
212216
$path = realpath($this->convertIdToPath($node));
217+
// phpcs:ignore: Ecg.Security.DiscouragedFunction.Discouraged
213218
if ($path && is_dir($path) && stripos($path, $currentPath) !== false) {
214219
$currentPath = $path;
215220
}
@@ -235,6 +240,7 @@ public function getCurrentPath()
235240
public function getCurrentUrl()
236241
{
237242
if (!$this->_currentUrl) {
243+
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
238244
$mediaPath = realpath(Mage::getConfig()->getOptions()->getMediaDir());
239245
$path = str_replace($mediaPath, '', $this->getCurrentPath());
240246
$path = trim($path, DS);
@@ -274,6 +280,7 @@ public function idEncode($string)
274280
public function idDecode($string)
275281
{
276282
$string = strtr($string, ':_-', '+/=');
283+
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
277284
return base64_decode($string);
278285
}
279286

app/code/core/Mage/Cms/Model/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function _construct()
5858
protected function _beforeSave()
5959
{
6060
$needle = 'block_id="' . $this->getBlockId() . '"';
61-
if (strstr($this->getContent(), $needle) == false) {
61+
if (!strstr($this->getContent(), $needle)) {
6262
return parent::_beforeSave();
6363
}
6464
Mage::throwException(

app/code/core/Mage/Cms/Model/Mysql4/Block.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* OpenMage
45
*
@@ -13,13 +14,17 @@
1314
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1415
*/
1516

17+
declare(strict_types=1);
18+
1619
/**
1720
* CMS block model
1821
*
1922
* @category Mage
2023
* @package Mage_Cms
2124
* @deprecated
25+
* @see Mage_Cms_Model_Resource_Block
2226
*/
27+
// phpcs:ignore: Ecg.Classes.Mysql4.Found
2328
class Mage_Cms_Model_Mysql4_Block extends Mage_Cms_Model_Resource_Block
2429
{
2530
}

app/code/core/Mage/Cms/Model/Mysql4/Block/Collection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* OpenMage
45
*
@@ -13,13 +14,17 @@
1314
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1415
*/
1516

17+
declare(strict_types=1);
18+
1619
/**
1720
* CMS block model
1821
*
1922
* @category Mage
2023
* @package Mage_Cms
2124
* @deprecated
25+
* @see Mage_Cms_Model_Resource_Block_Collection
2226
*/
27+
// phpcs:ignore: Ecg.Classes.Mysql4.Found
2328
class Mage_Cms_Model_Mysql4_Block_Collection extends Mage_Cms_Model_Resource_Block_Collection
2429
{
2530
}

0 commit comments

Comments
 (0)