Skip to content

Commit

Permalink
Add basic test to install and discover clients (#620)
Browse files Browse the repository at this point in the history
* Add basic test to install and discover clients

* Remove travis, use composer1
  • Loading branch information
barryvdh authored Sep 21, 2020
1 parent d8a8347 commit 048c42c
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 20 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Unit Tests

on:
push:
branches:
- master
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: [7.4, 7.3, 7.2]
dependency-version: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
- name: Execute Unit Tests
run: composer test
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@
"require-dev": {
"omnipay/tests": "^3"
},
"autoload-dev": {
"psr-4": { "Omnipay\\Tests\\" : "tests" }
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"scripts": {
"test": "phpunit"
},
"prefer-stable": true
}
22 changes: 22 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
35 changes: 35 additions & 0 deletions tests/OmnipayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Omnipay\Tests;

use Omnipay\Common\Http\Client;
use Omnipay\Omnipay;

class OmnipayTest extends TestCase
{
public function tearDown()
{
Omnipay::setFactory(null);

parent::tearDown();
}

public function testGetFactory()
{
Omnipay::setFactory(null);

$factory = Omnipay::getFactory();
$this->assertInstanceOf('Omnipay\Common\GatewayFactory', $factory);
}


/**
* Verify a new Client instance can be instantiated
*/
public function testNewClient()
{
$client = new Client();

$this->assertInstanceOf('Omnipay\Common\Http\Client', $client);
}
}

0 comments on commit 048c42c

Please sign in to comment.