-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple CI pipeline with basic PHP test runner (#823)
* add initial PHP test workflow test matrix contains all currently released and supported PHP versions * actually run the tests as described in tests/README * tests: fix PHPUnit imports * tests: fix missing constant S9Y_INCLUDE_PATH * tests: fix PHPUnit deprecation warning: DataProviders must be static ``` 2 tests triggered 2 PHPUnit deprecations: 1) functionsTest::test_serendipity_serverOffsetHour Data Provider method functionsTest::serverOffsetHourDataProvider() is not static /home/runner/work/Serendipity/Serendipity/tests/include/functionsTest.php:17 2) functionsTest::test_serendipity_serverOffsetHourWithTimestampNull Data Provider method functionsTest::serverOffsetHourWithTimestampNullDataProvider() is not static /home/runner/work/Serendipity/Serendipity/tests/include/functionsTest.php:46 ``` * tests: migrate PHPUnit XML configuration to version 11.0 ``` There was 1 PHPUnit test runner deprecation: 1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"! ``` * tests: disable code coverage for now * tests: migrate doc-comments to Attributes ``` There were 3 PHPUnit test runner deprecations: 1) Metadata found in doc-comment for method functionsConfigTest::test_serendipity_getTemplateFile(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. 2) Metadata found in doc-comment for method functionsTest::test_serendipity_serverOffsetHour(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. 3) Metadata found in doc-comment for method functionsTest::test_serendipity_serverOffsetHourWithTimestampNull(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. ``` * tests: fix assertions `assertContains()` is used for arrays etc., but we only have a string. Use `assertStringEndsWith()` instead, the _ends with_ also makes the test more robust. * tests: also run on PHP 7.4
- Loading branch information
Showing
5 changed files
with
97 additions
and
64 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,39 @@ | ||
# This workflow will run the tests on various versions of PHP. | ||
|
||
name: PHP Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: [opened] | ||
# TODO: enable to run once a week regardless of commits, but this will expire if repo is inactive for a longer time | ||
# schedule: | ||
# - cron: '12 3 4 * *' | ||
|
||
jobs: | ||
test-php: | ||
name: Run PHP Tests | ||
|
||
runs-on: ubuntu-22.04 | ||
|
||
# for available versions see https://github.com/marketplace/actions/setup-php-action#tada-php-support | ||
strategy: | ||
matrix: | ||
phpversion: ['7.4', '8.1', '8.2', '8.3'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup PHP and dependencies | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.phpversion }} | ||
extensions: pdo-sqlite | ||
tools: phpunit | ||
# TODO: enable coverage check | ||
coverage: none | ||
env: | ||
fail-fast: true | ||
- name: Run Tests | ||
run: | | ||
cd tests | ||
phpunit --configuration config.xml.dist include/* |
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
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 |
---|---|---|
@@ -1,28 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<phpunit bootstrap="bootstrap.php" | ||
backupGlobals="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
colors="true"> | ||
<php> | ||
<const name="IN_serendipity" value="true"/> | ||
<!--<const name="IS_installed" value="true"/>--> | ||
<!--<const name="USERLEVEL_ADMIN" value="255"/>--> | ||
<!--<const name="USERLEVEL_CHIEF" value="1"/>--> | ||
<!--<const name="USERLEVEL_EDITOR" value="0"/>--> | ||
<!--<const name="DB_DSN" value="sqlite:dbname=s9y_test;host=localhost" />--> | ||
<!--<const name="DB_HOST" value="localhost" />--> | ||
<!--<const name="DB_TYPE" value="pdo-sqlite" />--> | ||
<!--<const name="DB_USER" value="s9y_test" />--> | ||
<!--<const name="DB_PASSWD" value="s9y_test" />--> | ||
<!--<const name="DB_DBNAME" value="s9y_test" />--> | ||
<!--<const name="TEST_DB" value="test.db" />--> | ||
<!--<const name="PATH_SMARTY_COMPILE" value="templates_c" />--> | ||
</php> | ||
<testsuites> | ||
<testsuite name="include"> | ||
<directory>../tests/include</directory> | ||
</testsuite> | ||
</testsuites> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" backupGlobals="true" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache"> | ||
<php> | ||
<const name="IN_serendipity" value="true"/> | ||
<!--<const name="IS_installed" value="true"/>--> | ||
<!--<const name="USERLEVEL_ADMIN" value="255"/>--> | ||
<!--<const name="USERLEVEL_CHIEF" value="1"/>--> | ||
<!--<const name="USERLEVEL_EDITOR" value="0"/>--> | ||
<!--<const name="DB_DSN" value="sqlite:dbname=s9y_test;host=localhost" />--> | ||
<!--<const name="DB_HOST" value="localhost" />--> | ||
<!--<const name="DB_TYPE" value="pdo-sqlite" />--> | ||
<!--<const name="DB_USER" value="s9y_test" />--> | ||
<!--<const name="DB_PASSWD" value="s9y_test" />--> | ||
<!--<const name="DB_DBNAME" value="s9y_test" />--> | ||
<!--<const name="TEST_DB" value="test.db" />--> | ||
<!--<const name="PATH_SMARTY_COMPILE" value="templates_c" />--> | ||
</php> | ||
<testsuites> | ||
<testsuite name="include"> | ||
<directory>../tests/include</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source/> | ||
</phpunit> |