Skip to content

Commit 3be9692

Browse files
authored
Merge pull request #212 from picqer/github-actions
PHP 7.3 minimum required, Use Github Actions
2 parents 107a725 + dd6a170 commit 3be9692

File tree

11 files changed

+95
-33
lines changed

11 files changed

+95
-33
lines changed

.github/workflows/phpunit.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run phpunit
2+
on: [ push ]
3+
4+
jobs:
5+
test:
6+
strategy:
7+
matrix:
8+
php-versions: [ '7.3', '7.4', '8.0' ]
9+
name: PHP ${{ matrix.php-versions }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: ${{ matrix.php-versions }}
18+
- name: PHP version check
19+
run: php -v
20+
- name: Composer install
21+
run: composer install --prefer-dist --no-interaction --no-progress --no-suggest
22+
- name: Run tests
23+
run: vendor/bin/phpunit

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# moneybird-php-client
22

3-
[![Build Status](https://travis-ci.org/picqer/moneybird-php-client.svg?branch=master)](https://travis-ci.org/picqer/moneybird-php-client)
3+
![Run phpunit](https://github.com/picqer/moneybird-php-client/workflows/Run%20phpunit/badge.svg)
44

55
PHP Client for Moneybird V2
66

composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.6.0",
19+
"php": ">=7.3.0",
2020
"guzzlehttp/guzzle": "^6.3.1|^7.0",
2121
"psr/http-client": "^1.0",
2222
"ext-json": "*"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "~4.0"
25+
"phpunit/phpunit": "^8.5|^9.3",
26+
"phpspec/prophecy-phpunit": "^2.0"
2627
},
2728
"autoload": {
2829
"psr-4": {
2930
"Picqer\\Financials\\Moneybird\\": "src/Picqer/Financials/Moneybird"
3031
}
3132
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Picqer\\Tests\\": "tests/"
36+
}
37+
},
3238
"scripts": {
3339
"test": "vendor/bin/phpunit"
3440
}

phpunit.xml.dist

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="./vendor/autoload.php"
3-
colors="true">
4-
<testsuites>
5-
<testsuite>
6-
<directory>tests</directory>
7-
</testsuite>
8-
</testsuites>
9-
<filter>
10-
<whitelist>
11-
<directory suffix=".php">src</directory>
12-
</whitelist>
13-
</filter>
14-
</phpunit>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="moneybird-php-tests">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
</phpunit>

phpunit.xml.dist.bak

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="./vendor/autoload.php"
3+
colors="true">
4+
<testsuites>
5+
<testsuite name="moneybird-php-tests">
6+
<directory>tests</directory>
7+
</testsuite>
8+
</testsuites>
9+
<filter>
10+
<whitelist>
11+
<directory suffix=".php">src</directory>
12+
</whitelist>
13+
</filter>
14+
</phpunit>

tests/ApiTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
namespace Picqer\Tests;
4+
5+
use PHPUnit\Framework\MockObject\MockObject;
6+
use PHPUnit\Framework\TestCase;
37
use Picqer\Financials\Moneybird\Connection;
48
use Picqer\Financials\Moneybird\Moneybird;
59

@@ -10,26 +14,26 @@
1014
* - indicates what the mocked Connection object should expect when interacting with the Client / Entities
1115
* - actually interact with the Client / Entities
1216
*/
13-
class ApiTest extends \PHPUnit_Framework_TestCase
17+
class ApiTest extends TestCase
1418
{
1519
/**
16-
* @var \Picqer\Financials\Moneybird\Moneybird
20+
* @var Moneybird
1721
*/
1822
private $client;
1923

2024
/**
21-
* @var \Picqer\Financials\Moneybird\Connection
25+
* @var Connection
2226
*/
2327
private $connection;
2428

2529
/**
2630
* Same as self::$connection, only differently typed to enable autocompletion in IDE.
2731
*
28-
* @var \PHPUnit_Framework_MockObject_MockObject
32+
* @var MockObject
2933
*/
3034
private $mockedConnection;
3135

32-
public function setUp()
36+
protected function setUp(): void
3337
{
3438
$this->connection = $this->getMockBuilder(Connection::class)->getMock();
3539
$this->connection->setTesting(true);

tests/ConnectionTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?php
22

3+
namespace Picqer\Tests;
4+
35
use GuzzleHttp\Exception\BadResponseException;
46
use GuzzleHttp\Middleware;
57
use GuzzleHttp\Promise\PromiseInterface;
68
use GuzzleHttp\Psr7;
9+
use PHPUnit\Framework\TestCase;
710
use Picqer\Financials\Moneybird\Connection;
811
use Picqer\Financials\Moneybird\Entities\Contact;
912
use Picqer\Financials\Moneybird\Exceptions\Api\TooManyRequestsException;
13+
use Picqer\Financials\Moneybird\Exceptions\ApiException;
1014
use Psr\Http\Message\RequestInterface;
1115
use Psr\Http\Message\ResponseInterface;
1216

@@ -15,7 +19,7 @@
1519
*
1620
* Tests the connection for proper headers, authentication and other stuff
1721
*/
18-
class ConnectionTest extends \PHPUnit_Framework_TestCase
22+
class ConnectionTest extends TestCase
1923
{
2024
/**
2125
* Container to hold the Guzzle history (by reference).
@@ -27,7 +31,7 @@ class ConnectionTest extends \PHPUnit_Framework_TestCase
2731
/**
2832
* @param callable[] $additionalMiddlewares
2933
*
30-
* @return \Picqer\Financials\Moneybird\Connection
34+
* @return Connection
3135
*/
3236
private function getConnectionForTesting(array $additionalMiddlewares = [])
3337
{
@@ -66,7 +70,7 @@ private function getRequestFromHistoryContainer($requestNumber = 0)
6670
}
6771

6872
/**
69-
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
73+
* @throws ApiException
7074
*/
7175
public function testClientIncludesAuthenticationHeader()
7276
{
@@ -80,7 +84,7 @@ public function testClientIncludesAuthenticationHeader()
8084
}
8185

8286
/**
83-
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
87+
* @throws ApiException
8488
*/
8589
public function testClientIncludesJsonHeaders()
8690
{
@@ -95,7 +99,7 @@ public function testClientIncludesJsonHeaders()
9599
}
96100

97101
/**
98-
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
102+
* @throws ApiException
99103
*/
100104
public function testClientTriesToGetAccessTokenWhenNoneGiven()
101105
{
@@ -116,7 +120,7 @@ public function testClientTriesToGetAccessTokenWhenNoneGiven()
116120
}
117121

118122
/**
119-
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
123+
* @throws ApiException
120124
*/
121125
public function testClientContinuesWithRequestAfterGettingAccessTokenWhenNoneGiven()
122126
{
@@ -131,7 +135,7 @@ public function testClientContinuesWithRequestAfterGettingAccessTokenWhenNoneGiv
131135
}
132136

133137
/**
134-
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
138+
* @throws ApiException
135139
*/
136140
public function testClientDetectsApiRateLimit()
137141
{

tests/EntityTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
namespace Picqer\Tests;
4+
5+
use PHPUnit\Framework\TestCase;
36
use Picqer\Financials\Moneybird\Entities\Administration;
47
use Picqer\Financials\Moneybird\Entities\Contact;
58
use Picqer\Financials\Moneybird\Entities\ContactCustomField;
@@ -47,7 +50,7 @@
4750
* Tests all entities to ensure entities have no PHP parse errors and have
4851
* at least the properties we need to use the entity
4952
*/
50-
class EntityTest extends \PHPUnit_Framework_TestCase
53+
class EntityTest extends TestCase
5154
{
5255
public function testAdministrationEntity()
5356
{

tests/PicqerTest/Financials/Moneybird/Entities/SalesInvoice/SendInvoiceOptionsTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ public function testMethodIsValidated()
3939
self::fail('Should have thrown exception');
4040
} catch (InvalidArgumentException $e) {
4141
foreach ($this->validMethods as $validMethod) {
42-
self::assertContains($validMethod, $e->getMessage());
42+
self::assertStringContainsString($validMethod, $e->getMessage());
4343
}
4444

45-
self::assertContains('some-invalid-method', $e->getMessage(), 'Did not provide which value is invalid');
45+
self::assertStringContainsString('some-invalid-method', $e->getMessage(),
46+
'Did not provide which value is invalid');
4647
}
4748
}
4849

tests/PicqerTest/Financials/Moneybird/Entities/SalesInvoiceTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
use Picqer\Financials\Moneybird\Connection;
88
use Picqer\Financials\Moneybird\Entities\SalesInvoice;
99
use Prophecy\Argument\Token\AnyValueToken;
10+
use Prophecy\PhpUnit\ProphecyTrait;
1011
use Prophecy\Prophecy\ObjectProphecy;
1112

1213
class SalesInvoiceTest extends TestCase
1314
{
15+
use ProphecyTrait;
16+
1417
/** @var SalesInvoice */
1518
private $salesInvoice;
1619
/** @var ObjectProphecy */
@@ -20,7 +23,7 @@ class SalesInvoiceTest extends TestCase
2023
/** @var array */
2124
private $optionsJson;
2225

23-
protected function setUp()
26+
protected function setUp(): void
2427
{
2528
parent::setUp();
2629

@@ -40,12 +43,14 @@ public function testSendInvoiceThrowsExceptionWhenNonOptionsPassed()
4043
$this->salesInvoice->sendInvoice(false);
4144
self::fail('Should have thrown exception');
4245
} catch (InvalidArgumentException $e) {
46+
$this->addToAssertionCount(1);
4347
}
4448

4549
try {
4650
$this->salesInvoice->sendInvoice(new \stdClass());
4751
self::fail('Should have thrown exception');
4852
} catch (InvalidArgumentException $e) {
53+
$this->addToAssertionCount(1);
4954
}
5055
}
5156

0 commit comments

Comments
 (0)