Skip to content

PHPUnit: added/updated tests #4758

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

Merged
merged 50 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
daf174c
tests
sreichel Apr 15, 2025
4f147d1
rector
sreichel Apr 15, 2025
40a1714
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 15, 2025
0d9da31
updated test groups
sreichel Apr 16, 2025
7c8d87b
updated tests
sreichel Apr 16, 2025
c38e7f7
updated tests
sreichel Apr 16, 2025
ca66b11
updated tests
sreichel Apr 17, 2025
a1f65c2
updated tests
sreichel Apr 17, 2025
ac3a956
updated tests
sreichel Apr 17, 2025
8395a83
updated tests
sreichel Apr 17, 2025
d30e9f5
updated tests
sreichel Apr 17, 2025
c39085a
updated tests
sreichel Apr 17, 2025
fbc0367
updated tests
sreichel Apr 17, 2025
cb7fcff
updated tests
sreichel Apr 17, 2025
baf6ac7
updated tests
sreichel Apr 17, 2025
2b611a6
update
sreichel Apr 17, 2025
ef60fa0
update
sreichel Apr 17, 2025
2b8504f
update
sreichel Apr 17, 2025
e402396
update
sreichel Apr 17, 2025
22372a5
update
sreichel Apr 17, 2025
f14d4f8
typo
sreichel Apr 17, 2025
3838726
Merge branch 'OpenMage:main' into phpunit-pre-symfony
sreichel Apr 17, 2025
3dc1304
updated tests
sreichel Apr 17, 2025
8d179d6
updated tests
sreichel Apr 17, 2025
f25ae01
updated tests
sreichel Apr 17, 2025
64b1ebf
updated tests
sreichel Apr 17, 2025
3693bdf
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 19, 2025
716860f
sonar 1
sreichel Apr 19, 2025
78c163f
sonar 2
sreichel Apr 19, 2025
1607352
phpcs/phpstan
sreichel Apr 19, 2025
1b8c55e
sonar 4
sreichel Apr 19, 2025
59acdde
sonar 5
sreichel Apr 19, 2025
47af7e2
sonar 6
sreichel Apr 19, 2025
14d8f93
phpcs
sreichel Apr 19, 2025
be54c27
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 20, 2025
e1a5314
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 21, 2025
abde534
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 21, 2025
b4a8cf3
copyright, ref #4767
sreichel Apr 21, 2025
3ca8ce3
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 22, 2025
ab93118
added Makefile
sreichel Apr 25, 2025
a8e6d89
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 25, 2025
76f1cd4
Merge branch 'main' into phpunit-pre-symfony
sreichel Apr 27, 2025
3b72f4a
Merge branch 'main' into phpunit-pre-symfony
sreichel May 1, 2025
13523bc
Merge branch 'main' into phpunit-pre-symfony
sreichel May 5, 2025
f9bf285
merge fix
sreichel May 5, 2025
ec57883
Merge branch 'main' into phpunit-pre-symfony
sreichel May 5, 2025
63e5f77
reverted all changes to core files
sreichel May 6, 2025
ac7c2bb
Merge branch 'main' into phpunit-pre-symfony
sreichel May 6, 2025
dc817dd
Revert "reverted all changes to core files"
sreichel May 6, 2025
e194782
Merge remote-tracking branch 'origin/phpunit-pre-symfony' into phpuni…
sreichel May 6, 2025
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

/README.md export-ignore

/Makefile export-ignore

# Enforce checkout with linux lf consistent over all platforms
*.html text eol=lf
*.css text eol=lf
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
phpunit-result-cache-

- name: Run phpUnit
run: php vendor/bin/phpunit --configuration .phpunit.dist.xml
run: php vendor/bin/phpunit --configuration .phpunit.dist.xml --testsuite Base,Error,Mage,Varien

- name: Save result cache
uses: actions/cache/save@v4
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// PHP84: Adds or removes ? before single type declarations or |null at the end of union types when parameters have a default null value.
'nullable_type_declaration_for_default_null_value' => true,
// Calls to PHPUnit\Framework\TestCase static methods must all be of the same type, either $this->, self:: or static::
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'php_unit_test_case_static_method_calls' => ['call_type' => 'static'],
// Convert double quotes to single quotes for simple strings.
'single_quote' => true,
// Arguments lists, array destructuring lists, arrays that are multi-line, match-lines and parameters lists must have a trailing comma.
Expand Down
75 changes: 75 additions & 0 deletions .phpunit.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,81 @@
<testsuite name="Mage">
<directory>tests/unit/Mage</directory>
</testsuite>
<testsuite name="Mage_Admin">
<directory>tests/unit/Mage/Admin</directory>
</testsuite>
<testsuite name="Mage_Adminhtml">
<directory>tests/unit/Mage/Adminhtml</directory>
</testsuite>
<testsuite name="Mage_AdminNotification">
<directory>tests/unit/Mage/AdminNotification</directory>
</testsuite>
<testsuite name="Mage_Api">
<directory>tests/unit/Mage/Api</directory>
</testsuite>
<testsuite name="Mage_Catalog">
<directory>tests/unit/Mage/Catalog</directory>
</testsuite>
<testsuite name="Mage_Cms">
<directory>tests/unit/Mage/Cms</directory>
</testsuite>
<testsuite name="Mage_Contacts">
<directory>tests/unit/Mage/Contacts</directory>
</testsuite>
<testsuite name="Mage_Core">
<directory>tests/unit/Mage/Core</directory>
</testsuite>
<testsuite name="Mage_Customer">
<directory>tests/unit/Mage/Customer</directory>
</testsuite>
<testsuite name="Mage_Directory">
<directory>tests/unit/Mage/Directory</directory>
</testsuite>
<testsuite name="Mage_Downloadable">
<directory>tests/unit/Mage/Downloadable</directory>
</testsuite>
<testsuite name="Mage_Eav">
<directory>tests/unit/Mage/Eav</directory>
</testsuite>
<testsuite name="Mage_GiftMessage">
<directory>tests/unit/Mage/GiftMessage</directory>
</testsuite>
<testsuite name="Mage_Index">
<directory>tests/unit/Mage/Index</directory>
</testsuite>
<testsuite name="Mage_Log">
<directory>tests/unit/Mage/Log</directory>
</testsuite>
<testsuite name="Mage_Newsletter">
<directory>tests/unit/Mage/Newsletter</directory>
</testsuite>
<testsuite name="Mage_Page">
<directory>tests/unit/Mage/Page</directory>
</testsuite>
<testsuite name="Mage_Reports">
<directory>tests/unit/Mage/Reports</directory>
</testsuite>
<testsuite name="Mage_Review">
<directory>tests/unit/Mage/Review</directory>
</testsuite>
<testsuite name="Mage_Rule">
<directory>tests/unit/Mage/Rule</directory>
</testsuite>
<testsuite name="Mage_Sales">
<directory>tests/unit/Mage/Sales</directory>
</testsuite>
<testsuite name="Mage_Sitemap">
<directory>tests/unit/Mage/Sitemap</directory>
</testsuite>
<testsuite name="Mage_Tax">
<directory>tests/unit/Mage/Tax</directory>
</testsuite>
<testsuite name="Mage_Uploader">
<directory>tests/unit/Mage/Uploader</directory>
</testsuite>
<testsuite name="Mage_Wishlist">
<directory>tests/unit/Mage/Wishlist</directory>
</testsuite>
<testsuite name="Varien">
<directory>tests/unit/Varien</directory>
</testsuite>
Expand Down
3 changes: 3 additions & 0 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Rector\Php82\Rector as Php82;
use Rector\Php83\Rector as Php83;
use Rector\Php84\Rector as Php84;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\TypeDeclaration\Rector as TypeDeclaration;

try {
Expand Down Expand Up @@ -49,6 +50,8 @@
Php80\Class_\ClassPropertyAssignToConstructorPromotionRector::class, # todo: wait for php80
Php80\Class_\StringableForToStringRector::class, # todo: wait for php80
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
# use static methods
PreferPHPUnitThisCallRector::class,
__DIR__ . '/shell/translations.php',
__DIR__ . '/shell/update-copyright.php',
__DIR__ . '/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php',
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mkdocs-serve:
@if command -v mkdocs >/dev/null ; then \
mkdocs serve; \
else \
echo "mkdocs is not installed, see https://docs.openmage.org/developers/mkdocs/" && exit 2; \
fi; \

phpunit-serve:
@if test -f build/coverage/index.html ; then \
xdg-open build/coverage/index.html; \
else \
echo "phpunit coverage not found, run \"composer run phpunit:coverage-local\"" && exit 2; \
fi; \
13 changes: 6 additions & 7 deletions app/code/core/Mage/Adminhtml/Block/Cache/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ public function decorateStatus($value, $row, $column, $isExport)
{
$class = '';
if (isset($this->_invalidatedTypes[$row->getId()])) {
$cell = '<span class="grid-severity-minor"><span>' . $this->__('Invalidated') . '</span></span>';
$class = self::CSS_SEVERITY_MINOR;
$value = $this->__('Invalidated');
} elseif ($row->getStatus()) {
$class = self::CSS_SEVERITY_NOTICE;
} else {
if ($row->getStatus()) {
$cell = '<span class="grid-severity-notice"><span>' . $value . '</span></span>';
} else {
$cell = '<span class="grid-severity-critical"><span>' . $value . '</span></span>';
}
$class = self::CSS_SEVERITY_CRITICAL;
}
return $cell;
return sprintf(self::PATTERN_SEVERITY, $class, $value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;

/**
* Adminhtml permissions orphanedResource grid
*
Expand Down Expand Up @@ -75,7 +77,7 @@ protected function _prepareMassaction()
$this->setMassactionIdField('resource_id');
$this->getMassactionBlock()->setFormFieldName('resource_id');

$this->getMassactionBlock()->addItem('delete', [
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
'label' => Mage::helper('adminhtml')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('adminhtml')->__('Are you sure you want to do this?'),
Expand Down
6 changes: 6 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
*/
class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
{
public const PATTERN_SEVERITY = '<span class="%s"><span>%s</span></span>';
public const CSS_SEVERITY_CRITICAL = 'grid-severity-critical';
public const CSS_SEVERITY_MAJOR = 'grid-severity-major';
public const CSS_SEVERITY_MINOR = 'grid-severity-minor';
public const CSS_SEVERITY_NOTICE = 'grid-severity-notice';

/**
* Columns array
*
Expand Down
26 changes: 20 additions & 6 deletions app/code/core/Mage/Cms/Block/Widget/Page/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function getHref()
* as parameter or retrieve page title from DB using passed identifier or page id.
*
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
public function getTitle()
{
Expand All @@ -77,10 +78,9 @@ public function getTitle()
// compare to null used here bc user can specify blank title
$this->_title = $this->getData('title');
} elseif ($this->getData('page_id')) {
$this->_title = Mage::getResourceSingleton('cms/page')->getCmsPageTitleById($this->getData('page_id'));
$this->_title = $this->getCmsPageTitleById($this->getData('page_id'));
} elseif ($this->getData('href')) {
$this->_title = Mage::getResourceSingleton('cms/page')->setStore(Mage::app()->getStore())
->getCmsPageTitleByIdentifier($this->getData('href'));
$this->_title = $this->getCmsPageTitleByIdentifier($this->getData('href'));
}
}

Expand All @@ -93,6 +93,7 @@ public function getTitle()
* if title will be blank string, page identifier will be used.
*
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
public function getAnchorText()
{
Expand All @@ -101,14 +102,27 @@ public function getAnchorText()
} elseif ($this->getTitle()) {
$this->_anchorText = $this->getTitle();
} elseif ($this->getData('href')) {
$this->_anchorText = Mage::getResourceSingleton('cms/page')->setStore(Mage::app()->getStore())
->getCmsPageTitleByIdentifier($this->getData('href'));
$this->_anchorText = $this->getCmsPageTitleByIdentifier($this->getData('href'));
} elseif ($this->getData('page_id')) {
$this->_anchorText = Mage::getResourceSingleton('cms/page')->getCmsPageTitleById($this->getData('page_id'));
$this->_anchorText = $this->getCmsPageTitleById($this->getData('page_id'));
} else {
$this->_anchorText = $this->getData('href');
}

return $this->_anchorText;
}

protected function getCmsPageTitleById(int|string $pageId): string
{
return Mage::getResourceSingleton('cms/page')->getCmsPageTitleById($pageId);
}

/**
* @throws Mage_Core_Model_Store_Exception
*/
protected function getCmsPageTitleByIdentifier(int|string $identifier): string
{
return Mage::getResourceSingleton('cms/page')->setStore(Mage::app()->getStore())
->getCmsPageTitleByIdentifier($identifier);
}
}
8 changes: 3 additions & 5 deletions app/code/core/Mage/Core/Helper/Array.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ public function mergeRecursiveWithoutOverwriteNumKeys(array $baseArray, array $m
} else {
$baseArray[$key] = $value;
}
} elseif ($key) {
$baseArray[$key] = $value;
} else {
if ($key) {
$baseArray[$key] = $value;
} else {
$baseArray[] = $value;
}
$baseArray[] = $value;
}
}

Expand Down
18 changes: 10 additions & 8 deletions app/code/core/Mage/Index/Block/Adminhtml/Process/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct()
* Prepare grid collection
*
* @return $this
* @throws Exception
*/
protected function _prepareCollection()
{
Expand All @@ -66,6 +67,7 @@ protected function _prepareCollection()
* Add name and description to collection elements
*
* @return $this
* @throws Mage_Core_Exception
*/
protected function _afterLoadCollection()
{
Expand All @@ -89,10 +91,10 @@ protected function _afterLoadCollection()
* Prepare grid columns
*
* @return $this
* @throws Exception
*/
protected function _prepareColumns()
{
$baseUrl = $this->getUrl();
$this->addColumn('indexer_code', [
'header' => Mage::helper('index')->__('Index'),
'width' => '180',
Expand Down Expand Up @@ -183,16 +185,16 @@ public function decorateStatus($value, $row, $column, $isExport)
$class = '';
switch ($row->getStatus()) {
case Mage_Index_Model_Process::STATUS_PENDING:
$class = 'grid-severity-notice';
$class = self::CSS_SEVERITY_NOTICE;
break;
case Mage_Index_Model_Process::STATUS_RUNNING:
$class = 'grid-severity-major';
$class = self::CSS_SEVERITY_MAJOR;
break;
case Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX:
$class = 'grid-severity-critical';
$class = self::CSS_SEVERITY_CRITICAL;
break;
}
return '<span class="' . $class . '"><span>' . $value . '</span></span>';
return sprintf(self::PATTERN_SEVERITY, $class, $value);
}

/**
Expand All @@ -210,13 +212,13 @@ public function decorateUpdateRequired($value, $row, $column, $isExport)
$class = '';
switch ($row->getUpdateRequired()) {
case 0:
$class = 'grid-severity-notice';
$class = self::CSS_SEVERITY_NOTICE;
break;
case 1:
$class = 'grid-severity-critical';
$class = self::CSS_SEVERITY_CRITICAL;
break;
}
return '<span class="' . $class . '"><span>' . $value . '</span></span>';
return sprintf(self::PATTERN_SEVERITY, $class, $value);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Index/Model/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getProcessesCollection()
* Get index process by specific id
*
* @param int $processId
* @return Mage_Index_Model_Process | false
* @return Mage_Index_Model_Process|false
*/
public function getProcessById($processId)
{
Expand Down
6 changes: 6 additions & 0 deletions app/code/core/Mage/Index/Model/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* @method string getIndexCode()
* @method string getIndexerCode()
* @method $this setIndexerCode(string $value)
* @method string getName()
* @method $this setName(string $value)
* @method string getDescription()
* @method $this setDescription(string $value)
* @method string getStatus()
* @method $this setStatus(string $value)
* @method string getStartedAt()
Expand All @@ -33,6 +37,8 @@
* @method $this setMode(string $value)
* @method bool getForcePartialReindex()
* @method $this setForcePartialReindex(bool $value)
* @method int getUpdateRequired()
* @method $this setUpdateRequired(int $value)
*/
class Mage_Index_Model_Process extends Mage_Core_Model_Abstract
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Mage_Reports_Model_Resource_Report_Collection
/**
* Report period
*
* @var int
* @var string
*/
protected $_period;

Expand Down Expand Up @@ -76,7 +76,7 @@ protected function _construct() {}
/**
* Set period
*
* @param int $period
* @param string $period
* @return $this
*/
public function setPeriod($period)
Expand Down
Loading
Loading