Skip to content
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

add: phpunit, codecov & rector configs #17

Merged
merged 3 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

name: build

jobs:
phpunit:
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
with:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['7.4', '8.0', '8.1', '8.2', '8.3']
15 changes: 15 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on: [push, pull_request]

name: Workflow for Codecov

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: imanilchaudhari/yii2-currency-converter
21 changes: 21 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

name: rector

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
with:
os: >-
['ubuntu-latest']
php: >-
['7.4']
8 changes: 4 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</testsuites>

<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
7 changes: 7 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// ensure we get report on all possible php errors
error_reporting(-1);

require_once(__DIR__ . '/../vendor/autoload.php');
require_once __DIR__ . '/compatibility.php';
66 changes: 66 additions & 0 deletions tests/compatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/

/*
* Ensures compatibility with PHPUnit < 6.x
*/

namespace PHPUnit\Framework\Constraint {

if (!class_exists(\PHPUnit\Framework\Constraint\Constraint::class) && class_exists('PHPUnit_Framework_Constraint')) {
abstract class Constraint extends \PHPUnit_Framework_Constraint
{
}
}
}

namespace PHPUnit\Framework {

if (!class_exists(\PHPUnit\Framework\TestCase::class) && class_exists('PHPUnit_Framework_TestCase')) {

echo "Applying compatibility patch for PHPUnit 6...\n";

abstract class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* @param string $exception
*/
public function expectException($exception)
{
$this->setExpectedException($exception);
}

/**
* @param string $message
*/
public function expectExceptionMessage($message)
{
$parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
if (in_array('expectExceptionMessage', $parentClassMethods)) {
parent::expectExceptionMessage($message);

return;
}
$this->setExpectedException($this->getExpectedException(), $message);
}

/**
* @param string $messageRegExp
*/
public function expectExceptionMessageRegExp($messageRegExp)
{
$parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
if (in_array('expectExceptionMessageRegExp', $parentClassMethods)) {
parent::expectExceptionMessageRegExp($messageRegExp);

return;
}
$this->setExpectedExceptionRegExp($this->getExpectedException(), $messageRegExp);
}
}
}
}