-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PhpUnit: use database for tests, added tests (#4138)
* 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 #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 * Updated composer scripts --------- Co-authored-by: Ng Kiat Siong <[email protected]>
- Loading branch information
Showing
69 changed files
with
3,847 additions
and
487 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
## Description: run PHPUnit | ||
## Usage: phpunit | ||
## Example: ddev phpunit | ||
|
||
php vendor/bin/phpunit --no-coverage "$@" --testdox |
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,9 @@ | ||
#!/bin/bash | ||
|
||
## Description: run PHPUnit with coverage | ||
## Usage: phpunit-coverage | ||
## Example: ddev phpunit-coverage | ||
|
||
enable_xdebug | ||
XDEBUG_MODE=coverage php vendor/bin/phpunit --testdox | ||
disable_xdebug |
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,9 @@ | ||
#!/bin/bash | ||
|
||
## Description: run PHPUnit with local HTML coverage | ||
## Usage: phpunit-coverage-local | ||
## Example: ddev phpunit-coverage-local | ||
|
||
enable_xdebug | ||
XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox | ||
disable_xdebug |
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 |
---|---|---|
|
@@ -10,16 +10,39 @@ on: | |
|
||
jobs: | ||
unit-tests: | ||
runs-on: [ubuntu-latest] | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
operating-system: [ubuntu-latest] | ||
php-versions: ['7.4', '8.3'] | ||
mysql-version: ['5.7', '8.0'] | ||
|
||
services: | ||
mysql: | ||
image: mysql:${{ matrix.mysql-version }} | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: db | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Validate mysql service | ||
run: | | ||
echo "Checking mysql service" | ||
sudo apt-get install -y mysql-client | ||
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -proot -e "SHOW DATABASES" | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
repository: OpenMage/Testfield | ||
path: ./ | ||
php-version: ${{ matrix.php-versions }} | ||
coverage: pcov #optional, setup coverage driver | ||
env: | ||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Validate composer | ||
run: composer validate | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
|
@@ -33,24 +56,61 @@ jobs: | |
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs | ||
|
||
- name: Checkout OpenMage repo | ||
uses: actions/checkout@v4 | ||
with: | ||
path: openmage | ||
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* | ||
|
||
- name: Install OpenMage dependencies | ||
working-directory: ./openmage | ||
run: composer install --prefer-dist --no-progress --ignore-platform-reqs --no-dev | ||
- name: Install OpenMage | ||
run: | | ||
php -f install.php -- \ | ||
--license_agreement_accepted 'yes' \ | ||
--locale 'en_US' \ | ||
--timezone 'America/New_York' \ | ||
--db_host '127.0.0.1' \ | ||
--db_name 'db' \ | ||
--db_user 'root' \ | ||
--db_pass 'root' \ | ||
--db_prefix '' \ | ||
--url 'http://openmage.local' \ | ||
--use_rewrites 'yes' \ | ||
--use_secure 'yes' \ | ||
--secure_base_url 'http://openmage.local' \ | ||
--use_secure_admin 'yes' \ | ||
--admin_username 'admin' \ | ||
--admin_lastname 'Administrator' \ | ||
--admin_firstname 'OpenMage' \ | ||
--admin_email '[email protected]' \ | ||
--admin_password 'veryl0ngpassw0rd' \ | ||
--session_save 'files' \ | ||
--admin_frontname 'admin' \ | ||
--backend_frontname 'admin' \ | ||
--default_currency 'USD' \ | ||
--enable_charts 'yes' \ | ||
--skip_url_validation 'yes' | ||
- name: run phpUnit | ||
run: bash ./run_unit_tests.sh | ||
- name: Run phpUnit | ||
run: php -f vendor/bin/phpunit | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2.7 | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
continue-on-error: true | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
files: output/*.xml | ||
files: tests/logging/*.xml | ||
|
||
- name: prepare SonarCloud Scan Data | ||
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }} | ||
run: | | ||
head tests/coverage/clover.xml | ||
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/logging/junit.xml | ||
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/coverage/clover.xml | ||
head ./tests/coverage/clover.xml | ||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
continue-on-error: true | ||
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }} && SONAR_TOKEN | ||
with: | ||
args: > | ||
-Dproject.settings=tests/sonar-project.properties | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -114,6 +114,7 @@ | |
'lib/Magento/', | ||
'lib/Varien/', | ||
'shell/', | ||
'tests/unit/', | ||
]) | ||
->name('*.php') | ||
->ignoreDotFiles(true) | ||
|
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
Oops, something went wrong.