Skip to content

Migrate from TravicCI to Github Actions #57

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
54 changes: 54 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: tests

on:
pull_request:
push:
branches: [ master ]

jobs:
unit-tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3

env:
EXECUTE_COVERAGE: ${{ matrix.php-version == '8.0' }}
CLOVER_PATH: "logs/clover.xml"

steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug

- if: matrix.php-version == '7.0' || matrix.php-version == '7.1'
run: composer config --no-plugins allow-plugins.kylekatarnls/update-helper true

- run: composer install --no-interaction --no-scripts --no-suggest --no-progress --optimize-autoloader

- if: env.EXECUTE_COVERAGE == 'true'
run: vendor/bin/phpunit --coverage-text --coverage-clover ${{ env.CLOVER_PATH }}

- if: env.EXECUTE_COVERAGE != 'true'
run: vendor/bin/phpunit

- if: env.EXECUTE_COVERAGE == 'true'
# This fails in forks
continue-on-error: true
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
!.github
vendor
.idea
.php_cs.cache
Expand Down
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
This rule will validate that a given credit card **number**, **expiration date** or **cvc** is valid.

<p align="center">
<a href="https://travis-ci.org/laravel-validation-rules/credit-card">
<img src="https://img.shields.io/travis/laravel-validation-rules/credit-card.svg?style=flat-square">
<a href="https://github.com/laravel-validation-rules/credit-card">
<img src="https://github.com/laravel-validation-rules/credit-card/workflows/tests/badge.svg">
</a>
<a href="https://scrutinizer-ci.com/g/laravel-validation-rules/credit-card/code-structure/master/code-coverage">
<img src="https://img.shields.io/scrutinizer/coverage/g/laravel-validation-rules/credit-card.svg?style=flat-square">
Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@

class TestCase extends \Orchestra\Testbench\TestCase
{
// The TestCase::__construct in the new PHPUnit versions requires first argument,
// this workaround allows to instantiate test files in the tests.
public function __construct($name = null)
{
parent::__construct($name ?? get_class($this));
}
}
12 changes: 3 additions & 9 deletions tests/Unit/CardCvcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
use LVR\CreditCard\Cards\Card;
use LVR\CreditCard\Tests\TestCase;
use LVR\CreditCard\Tests\Unit\Cards\AmericanExpressTest;
use LVR\CreditCard\Tests\Unit\Cards\BaseCardTests;
use LVR\CreditCard\Tests\Unit\Cards\VisaTest;

class CardCvcTest extends TestCase
{
/** @test **/
public function it_check_cvc_by_credit_card()
{
$this->assertTrue($this->validator('243')->passes());
$this->assertTrue($this->validator('1234')->passes());

$this->assertTrue($this->validator('1234', new AmericanExpressTest)->passes());
$this->assertFalse($this->validator('243', new AmericanExpressTest)->passes()); // American Express supports only 4 digits

Expand Down Expand Up @@ -63,15 +61,11 @@ public function it_checks_cvc_code_length()

/**
* @param string|int $cvc
* @param null $testCard
* @param BaseCardTests $testCard
* @return mixed
*/
protected function validator($cvc, $testCard = null)
protected function validator($cvc, $testCard)
{
if (! $testCard) {
$testCard = new AmericanExpressTest();
}

return Validator::make(
[
'cvc' => $cvc,
Expand Down
11 changes: 5 additions & 6 deletions tests/Unit/CardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@

class CardTest extends TestCase
{
/** @test @dataProvider badStrings **/
public function it_expects_card_number($input)
public function it_expects_card_number()
{
$this->expectException(CreditCardException::class);

Factory::makeFromNumber($input);
Factory::makeFromNumber(null);
}

public function badStrings()
public function it_expects_not_empty_card_number()
{
return ['empty string' => [''], 'null' => [null]];
$this->expectException(CreditCardException::class);
Factory::makeFromNumber('');
}

/** @test **/
Expand Down