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)); + } +}