Skip to content

Commit 048c42c

Browse files
authored
Add basic test to install and discover clients (#620)
* Add basic test to install and discover clients * Remove travis, use composer1
1 parent d8a8347 commit 048c42c

File tree

5 files changed

+106
-20
lines changed

5 files changed

+106
-20
lines changed

.github/workflows/run-tests.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- "*"
10+
schedule:
11+
- cron: '0 0 * * *'
12+
13+
jobs:
14+
php-tests:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
env:
18+
COMPOSER_NO_INTERACTION: 1
19+
20+
strategy:
21+
matrix:
22+
php: [7.4, 7.3, 7.2]
23+
dependency-version: [prefer-lowest, prefer-stable]
24+
25+
name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v2
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php }}
35+
coverage: none
36+
tools: composer
37+
38+
- name: Install dependencies
39+
run: |
40+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
41+
42+
- name: Execute Unit Tests
43+
run: composer test

.travis.yml

-20
This file was deleted.

composer.json

+6
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
"require-dev": {
2929
"omnipay/tests": "^3"
3030
},
31+
"autoload-dev": {
32+
"psr-4": { "Omnipay\\Tests\\" : "tests" }
33+
},
3134
"extra": {
3235
"branch-alias": {
3336
"dev-master": "3.0.x-dev"
3437
}
3538
},
39+
"scripts": {
40+
"test": "phpunit"
41+
},
3642
"prefer-stable": true
3743
}

phpunit.xml.dist

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false">
12+
<testsuites>
13+
<testsuite name="Omnipay Test Suite">
14+
<directory>./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory>./src</directory>
20+
</whitelist>
21+
</filter>
22+
</phpunit>

tests/OmnipayTest.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Omnipay\Tests;
4+
5+
use Omnipay\Common\Http\Client;
6+
use Omnipay\Omnipay;
7+
8+
class OmnipayTest extends TestCase
9+
{
10+
public function tearDown()
11+
{
12+
Omnipay::setFactory(null);
13+
14+
parent::tearDown();
15+
}
16+
17+
public function testGetFactory()
18+
{
19+
Omnipay::setFactory(null);
20+
21+
$factory = Omnipay::getFactory();
22+
$this->assertInstanceOf('Omnipay\Common\GatewayFactory', $factory);
23+
}
24+
25+
26+
/**
27+
* Verify a new Client instance can be instantiated
28+
*/
29+
public function testNewClient()
30+
{
31+
$client = new Client();
32+
33+
$this->assertInstanceOf('Omnipay\Common\Http\Client', $client);
34+
}
35+
}

0 commit comments

Comments
 (0)