From d67a54a6b2fae89ae936b0730b2023d0d4019d4e Mon Sep 17 00:00:00 2001 From: james Date: Fri, 30 May 2025 20:57:14 +0800 Subject: [PATCH] new src --- .gitea/workflows/test.yml | 26 ++++++++++++++++++++++++++ composer.json | 19 +++++++++++++++++++ phpunit.xml | 19 +++++++++++++++++++ src/Calculator.php | 17 +++++++++++++++++ tests/CalculatorTest.php | 13 +++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 .gitea/workflows/test.yml create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 src/Calculator.php create mode 100644 tests/CalculatorTest.php diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 0000000..1f8b49b --- /dev/null +++ b/.gitea/workflows/test.yml @@ -0,0 +1,26 @@ +name: Run Unit Tests + +on: + push: + branches: + - main + - develop + pull_request: + +jobs: + test: + runs-on: phpunit_test + container: php:8.1-cli-alpine + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + apk add --no-cache git unzip + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer install --no-interaction --prefer-dist + + - name: Run PHPUnit tests + run: | + vendor/bin/phpunit --configuration phpunit.xml \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c02fbe0 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "example/php-woodpecker-demo", + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "autoload": { + "psr-4": { + "App\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "scripts": { + "test": "phpunit" + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..46f3c9d --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + + tests + + + + + + ./src + + + + + + diff --git a/src/Calculator.php b/src/Calculator.php new file mode 100644 index 0000000..164ba7d --- /dev/null +++ b/src/Calculator.php @@ -0,0 +1,17 @@ +assertEquals(5, $calc->add(2, 3)); + } +}