Skip to content

Commit

Permalink
Merge pull request #17 from imanilchaudhari/tests
Browse files Browse the repository at this point in the history
add: phpunit, codecov & rector configs
  • Loading branch information
imanilchaudhari authored Apr 6, 2024
2 parents 4f1b5fc + 30df477 commit 14c091d
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 4 deletions.
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);
}
}
}
}

0 comments on commit 14c091d

Please sign in to comment.