Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit: added some tests #4204

Merged
merged 105 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
3d7eaf6
Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)
sreichel Jul 22, 2024
53ee2f8
Merge branch 'OpenMage:main' into main
sreichel Jul 24, 2024
89cc37c
Merge branch 'OpenMage:main' into main
sreichel Jul 24, 2024
e939180
Merge branch 'OpenMage:main' into main
sreichel Jul 31, 2024
35c91ef
Merge branch 'OpenMage:main' into main
sreichel Jul 31, 2024
abb5279
Updated test
sreichel Aug 2, 2024
6aac86b
Added test
sreichel Aug 2, 2024
09ee18a
Added test
sreichel Aug 2, 2024
40559cf
Renamed and updated test
sreichel Aug 2, 2024
18f1903
Updated test
sreichel Aug 2, 2024
cf4340d
Updated test
sreichel Aug 2, 2024
656044b
Updated test
sreichel Aug 2, 2024
b9630c1
Updated test
sreichel Aug 2, 2024
6f0b4b7
Revert "Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)"
sreichel Aug 2, 2024
aa92e88
Updated test (phpstan L9)
sreichel Aug 2, 2024
f9e7b6f
Updated test (fixed namespace)
sreichel Aug 2, 2024
671107f
Updated test (phpstan L9)
sreichel Aug 2, 2024
475b8d4
Added unit test to code style check and phpstan
sreichel Aug 2, 2024
6d45ed6
Some cleanup
sreichel Aug 2, 2024
7f91768
Some cleanup
sreichel Aug 2, 2024
25d70a0
Some cleanup
sreichel Aug 2, 2024
57bd2a4
Updated workflow
sreichel Aug 2, 2024
2509777
ddev shortcut [ski ci]
sreichel Aug 3, 2024
4242f3a
Moved phphunit config file
sreichel Aug 3, 2024
aa26cca
Merged phpunit & sonar workflow
sreichel Aug 3, 2024
f4935f1
PhpUnit fix
sreichel Aug 4, 2024
dee0422
Fix linefeed (?)
sreichel Aug 4, 2024
47f6cae
Fix config
sreichel Aug 4, 2024
3df607b
Fixed invalid php version
sreichel Aug 4, 2024
0033475
Use minimum version
sreichel Aug 4, 2024
b19c11f
Use minimum version for SonarScan
sreichel Aug 4, 2024
e60b5c8
Fix command [ski ci]
sreichel Aug 4, 2024
bf03ca8
Enable xdebug
sreichel Aug 4, 2024
154229e
Added test, ref #4123
sreichel Aug 5, 2024
ed786cf
Merge branch 'main' into unit-tests
sreichel Aug 5, 2024
67a20fa
Revert "Some cleanup"
sreichel Aug 5, 2024
a0e5f9d
Revert "PhpUnit fix"
sreichel Aug 5, 2024
85bb579
Updated test
sreichel Aug 5, 2024
3e59b09
Updated docblocks
sreichel Aug 5, 2024
6238847
Revert "Fix linefeed (?)"
sreichel Aug 6, 2024
d9ec2c4
Merge branch 'main' into unit-tests
kiatng Aug 9, 2024
0965de1
Added tests
sreichel Aug 20, 2024
98366f5
Added tests
sreichel Aug 21, 2024
0100b36
Added tests [skip ci]
sreichel Aug 21, 2024
5c2b8a7
Merge branch 'main' into unit-tests
sreichel Aug 22, 2024
e55c6f3
Reverted changes to Mage_Core_Model_Website
sreichel Aug 24, 2024
6deb92f
Merge branch 'main' into unit-tests
sreichel Aug 24, 2024
4cd3c64
Updated config
sreichel Aug 28, 2024
cc5b55a
Updated .gitignore
sreichel Aug 28, 2024
47dda7a
Updated workflow
sreichel Aug 28, 2024
9f3010e
Merge branch 'main' into unit-tests
sreichel Aug 28, 2024
77a14b9
Updated workflow typo
sreichel Aug 28, 2024
a52e67f
Updated workflow continue on error
sreichel Aug 28, 2024
2f6592b
Updated workflow if condition
sreichel Aug 28, 2024
9d9c582
Updated workflow [skip ci]
sreichel Aug 28, 2024
7c7f930
Moved tests to root (as common)
sreichel Aug 28, 2024
e439e28
Fixed paths
sreichel Aug 28, 2024
7f46713
Fixed paths
sreichel Aug 28, 2024
78b2a0d
Fixed paths
sreichel Aug 28, 2024
f80be8e
CS fix
sreichel Aug 29, 2024
2dc091a
Added test
sreichel Aug 29, 2024
433b537
Added test
sreichel Aug 29, 2024
f31b912
Merge branch 'main' into unit-tests
kiatng Aug 30, 2024
9448e58
Added groups/suites
sreichel Sep 2, 2024
0c362c6
Updated test
sreichel Sep 2, 2024
a6ffaca
CS fix
sreichel Sep 2, 2024
cda06c7
Merge branch 'main' into unit-tests
sreichel Sep 2, 2024
0f0626b
Merge branch 'main' into unit-tests
sreichel Sep 3, 2024
6f05fc9
Updated .gitignore
sreichel Sep 4, 2024
e229c16
Updated phpunit.xml.dist
sreichel Sep 4, 2024
3eb7b19
Added test
sreichel Sep 4, 2024
e0e3cba
Added tests
sreichel Sep 4, 2024
a44184c
Added tests
sreichel Sep 4, 2024
2b00b85
Added tests
sreichel Sep 4, 2024
dbd6ff8
Added tests
sreichel Sep 4, 2024
d66894c
Merge remote-tracking branch 'origin/unit-tests' into unit-tests
sreichel Sep 4, 2024
453d168
Merge branch 'main' into unit-tests
sreichel Sep 4, 2024
0744d25
CS fix
sreichel Sep 4, 2024
dbe197b
CS fix
sreichel Sep 4, 2024
32eeee8
Added tests
sreichel Sep 4, 2024
63951f8
Added tests
sreichel Sep 4, 2024
7f8208b
Added tests
sreichel Sep 4, 2024
75e548a
Added tests
sreichel Sep 4, 2024
ba8108a
CS/PhpStan fixes
sreichel Sep 4, 2024
b0819e5
Update
sreichel Sep 4, 2024
59e38ea
Nicer output?
sreichel Sep 4, 2024
5a2d48a
Don't wait for phpcs
sreichel Sep 4, 2024
19354fb
Revert output
sreichel Sep 4, 2024
48221e0
Merge branch 'main' into unit-tests
sreichel Sep 6, 2024
e91a8d5
Merge branch 'main' into unit-tests
sreichel Sep 9, 2024
e814547
Updated workflows
sreichel Sep 9, 2024
c1a1b5f
Added test
sreichel Sep 9, 2024
737c5bc
Added phpunit command to composer.json
sreichel Sep 9, 2024
d9bb9af
Updated DDEV commands
sreichel Sep 9, 2024
c6ff127
Fixed phpunit commands at composer.json
sreichel Sep 9, 2024
26b53a6
WIP
sreichel Sep 16, 2024
31b8536
Merge branch 'main' into unit-2
sreichel Sep 17, 2024
8d43bfc
phpcs and phpstan fixes
sreichel Sep 18, 2024
e2f51f8
Merge branch 'main' into unit-2
sreichel Sep 18, 2024
1daa2b8
Updated tests
sreichel Sep 18, 2024
ca61f2e
Merge remote-tracking branch 'origin/unit-2' into unit-2
sreichel Sep 18, 2024
66536b6
Merge branch 'main' into unit-2
sreichel Sep 18, 2024
752ea06
Moved test to correct directory
sreichel Sep 18, 2024
5bdc08f
Added tests
sreichel Sep 18, 2024
bacf685
Merge remote-tracking branch 'origin/unit-2' into unit-2
sreichel Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ public function getDeleteButtonHtml()
*/
public function initForm()
{
/** @var Mage_Customer_Model_Customer $customer */
$customer = Mage::registry('current_customer');

$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('address_fieldset', [
'legend' => Mage::helper('customer')->__("Edit Customer's Address")]);

$customer = $this->getRegistryCurrentCustomer();
$addressModel = Mage::getModel('customer/address');
$addressModel->setCountryId(Mage::helper('core')->getDefaultCountry($customer->getStore()));
/** @var Mage_Customer_Model_Form $addressForm */
Expand Down Expand Up @@ -296,4 +294,9 @@ public function addValuesToNameSuffixElement($values)
}
return $this;
}

protected function getRegistryCurrentCustomer(): ?Mage_Customer_Model_Customer
{
return Mage::registry('current_customer');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function initForm()
{
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('_newsletter');
$customer = Mage::registry('current_customer');
$customer = $this->getRegistryCurrentCustomer();
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
Mage::register('subscriber', $subscriber);

Expand Down Expand Up @@ -95,4 +95,9 @@ protected function _prepareLayout()
);
return parent::_prepareLayout();
}

protected function getRegistryCurrentCustomer(): ?Mage_Customer_Model_Customer
{
return Mage::registry('current_customer');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function initForm()
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('_view');

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

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

return $this;
}

protected function getRegistryCurrentConvertProfile(): ?Mage_Dataflow_Model_Profile
{
return Mage::registry('current_convert_profile');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function initForm()
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('_edit');

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

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

return $this;
}

protected function getRegistryCurrentConvertProfile(): ?Mage_Dataflow_Model_Profile
{
return Mage::registry('current_convert_profile');
}
}
1 change: 1 addition & 0 deletions app/code/core/Mage/Cms/Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function match(Zend_Controller_Request_Http $request)
Mage::app()->getFrontController()->getResponse()
->setRedirect(Mage::getUrl('install'))
->sendResponse();
// phpcs:ignore: Ecg.Security.LanguageConstruct.ExitUsage
exit;
}

Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Cms/Helper/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pag
{
$page = Mage::getSingleton('cms/page');
if (!is_null($pageId) && $pageId !== $page->getId()) {
$delimeterPosition = strrpos($pageId, '|');
if ($delimeterPosition) {
$pageId = substr($pageId, 0, $delimeterPosition);
$delimiterPosition = strrpos($pageId, '|');
if ($delimiterPosition) {
$pageId = substr($pageId, 0, $delimiterPosition);
}

$page->setStoreId(Mage::app()->getStore()->getId());
Expand Down
7 changes: 7 additions & 0 deletions app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function getStorageRoot()
if (!$this->_storageRoot) {
$path = Mage::getConfig()->getOptions()->getMediaDir()
. DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY;
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
$this->_storageRoot = realpath($path);
if (!$this->_storageRoot) {
$this->_storageRoot = $path;
Expand Down Expand Up @@ -107,6 +108,7 @@ public function getTreeNodeName()
*/
public function convertPathToId($path)
{
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
$storageRoot = realpath($this->getStorageRoot());
$path = str_replace($storageRoot, '', $path);
return $this->idEncode($path);
Expand All @@ -121,6 +123,7 @@ public function convertPathToId($path)
public function convertIdToPath($id)
{
$path = $this->idDecode($id);
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
$storageRoot = realpath($this->getStorageRoot());
if (!strstr($path, $storageRoot)) {
$path = $storageRoot . DS . $path;
Expand Down Expand Up @@ -209,7 +212,9 @@ public function getCurrentPath()
$currentPath = $this->getStorageRoot();
$node = $this->_getRequest()->getParam($this->getTreeNodeName());
if ($node) {
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
$path = realpath($this->convertIdToPath($node));
// phpcs:ignore: Ecg.Security.DiscouragedFunction.Discouraged
if ($path && is_dir($path) && stripos($path, $currentPath) !== false) {
$currentPath = $path;
}
Expand All @@ -235,6 +240,7 @@ public function getCurrentPath()
public function getCurrentUrl()
{
if (!$this->_currentUrl) {
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
$mediaPath = realpath(Mage::getConfig()->getOptions()->getMediaDir());
$path = str_replace($mediaPath, '', $this->getCurrentPath());
$path = trim($path, DS);
Expand Down Expand Up @@ -274,6 +280,7 @@ public function idEncode($string)
public function idDecode($string)
{
$string = strtr($string, ':_-', '+/=');
// phpcs:ignore: Ecg.Security.ForbiddenFunction.Found
return base64_decode($string);
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Cms/Model/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function _construct()
protected function _beforeSave()
{
$needle = 'block_id="' . $this->getBlockId() . '"';
if (strstr($this->getContent(), $needle) == false) {
if (!strstr($this->getContent(), $needle)) {
return parent::_beforeSave();
}
Mage::throwException(
Expand Down
5 changes: 5 additions & 0 deletions app/code/core/Mage/Cms/Model/Mysql4/Block.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* OpenMage
*
Expand All @@ -13,13 +14,17 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

declare(strict_types=1);

/**
* CMS block model
*
* @category Mage
* @package Mage_Cms
* @deprecated
* @see Mage_Cms_Model_Resource_Block
*/
// phpcs:ignore: Ecg.Classes.Mysql4.Found
class Mage_Cms_Model_Mysql4_Block extends Mage_Cms_Model_Resource_Block
{
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Cms/Model/Mysql4/Block/Collection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* OpenMage
*
Expand All @@ -13,13 +14,17 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

declare(strict_types=1);

/**
* CMS block model
*
* @category Mage
* @package Mage_Cms
* @deprecated
* @see Mage_Cms_Model_Resource_Block_Collection
*/
// phpcs:ignore: Ecg.Classes.Mysql4.Found
class Mage_Cms_Model_Mysql4_Block_Collection extends Mage_Cms_Model_Resource_Block_Collection
{
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Cms/Model/Mysql4/Page.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* OpenMage
*
Expand All @@ -13,13 +14,17 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

declare(strict_types=1);

/**
* Cms page mysql resource
*
* @category Mage
* @package Mage_Cms
* @deprecated
* @see Mage_Cms_Model_Resource_Page
*/
// phpcs:ignore: Ecg.Classes.Mysql4.Found
class Mage_Cms_Model_Mysql4_Page extends Mage_Cms_Model_Resource_Page
{
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Cms/Model/Mysql4/Page/Collection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* OpenMage
*
Expand All @@ -13,13 +14,17 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

declare(strict_types=1);

/**
* CMS page collection
*
* @category Mage
* @package Mage_Cms
* @deprecated
* @see Mage_Cms_Model_Resource_Page_Collection
*/
// phpcs:ignore: Ecg.Classes.Mysql4.Found
class Mage_Cms_Model_Mysql4_Page_Collection extends Mage_Cms_Model_Resource_Page_Collection
{
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Cms/Model/Mysql4/Page/Service.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* OpenMage
*
Expand All @@ -13,13 +14,17 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

declare(strict_types=1);

/**
* Cms page service resource model
*
* @category Mage
* @package Mage_Cms
* @deprecated
* @see Mage_Cms_Model_Resource_Page_Service
*/
// phpcs:ignore: Ecg.Classes.Mysql4.Found
class Mage_Cms_Model_Mysql4_Page_Service extends Mage_Cms_Model_Resource_Page_Service
{
}
37 changes: 35 additions & 2 deletions app/code/core/Mage/Cms/Model/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class Mage_Cms_Model_Page extends Mage_Core_Model_Abstract
/**
* Page's Statuses
*/
public const STATUS_ENABLED = 1;
public const STATUS_ENABLED = 1;
public const STATUS_DISABLED = 0;

public const CACHE_TAG = 'cms_page';
public const CACHE_TAG = 'cms_page';
protected $_cacheTag = 'cms_page';

/**
Expand Down Expand Up @@ -124,6 +124,39 @@ public function checkIdentifier($identifier, $storeId)
return $this->_getResource()->checkIdentifier($identifier, $storeId);
}

/**
* Retrieves cms page title from DB by passed identifier.
*
* @param string $identifier
* @return string
*/
public function getCmsPageTitleByIdentifier(string $identifier): string
{
return $this->_getResource()->getCmsPageTitleByIdentifier($identifier);
}

/**
* Retrieves cms page title from DB by passed id.
*
* @param string|int $id
* @return string
*/
public function getCmsPageTitleById($id): string
{
return $this->_getResource()->getCmsPageTitleById($id);
}

/**
* Retrieves cms page identifier from DB by passed id.
*
* @param string|int $id
* @return string
*/
public function getCmsPageIdentifierById($id): string
{
return $this->_getResource()->getCmsPageIdentifierById($id);
}

/**
* Prepare page's statuses.
* Available event cms_page_get_available_statuses to customize statuses.
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Cms/Model/Resource/Block/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ protected function _renderFiltersBefore()
['store_table' => $this->getTable('cms/block_store')],
'main_table.block_id = store_table.block_id',
[]
// phpcs:ignore: Ecg.Sql.SlowQuery.SlowSql
)->group('main_table.block_id');

/*
* Allow analytic functions usage because of one field grouping
*/
$this->_useAnalyticFunction = true;
}
return parent::_renderFiltersBefore();
parent::_renderFiltersBefore();
}
}
4 changes: 2 additions & 2 deletions app/code/core/Mage/Cms/Model/Resource/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function checkIdentifier($identifier, $storeId)
/**
* Retrieves cms page title from DB by passed identifier.
*
* @param string $identifier
* @param string|int $identifier
* @return string
*/
public function getCmsPageTitleByIdentifier($identifier)
Expand All @@ -304,7 +304,7 @@ public function getCmsPageTitleByIdentifier($identifier)
/**
* Retrieves cms page title from DB by passed id.
*
* @param string $id
* @param string|int $id
* @return string
*/
public function getCmsPageTitleById($id)
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Cms/Model/Resource/Page/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@ protected function _renderFiltersBefore()
['store_table' => $this->getTable('cms/page_store')],
'main_table.page_id = store_table.page_id',
[]
// phpcs:ignore: Ecg.Sql.SlowQuery.SlowSql
)->group('main_table.page_id');

/*
* Allow analytic functions usage because of one field grouping
*/
$this->_useAnalyticFunction = true;
}
return parent::_renderFiltersBefore();
parent::_renderFiltersBefore();
}

/**
Expand Down
Loading