Skip to content

Commit 3f2b5c5

Browse files
author
B24io
committed
task#4858 add phpunit and travis
1 parent 69e5786 commit 3f2b5c5

File tree

5 files changed

+84
-4
lines changed

5 files changed

+84
-4
lines changed

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
- 7.2
6+
- 7.3
7+
- 7.4
8+
9+
sudo: false
10+
11+
cache:
12+
directories:
13+
- vendor
14+
- $HOME/.composer/cache
15+
16+
before_script:
17+
- composer self-update
18+
- composer install --no-interaction --prefer-source --dev
19+
20+
script:
21+
composer test

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
"symfony/http-foundation": "^4.2"
3636
},
3737
"require-dev": {
38-
"phpunit/phpunit": "^7",
39-
"jakub-onderka/php-parallel-lint": "0.9",
40-
"jakub-onderka/php-console-highlighter": "~0.3"
38+
"phpunit/phpunit": "^7"
4139
},
4240
"autoload": {
4341
"psr-4": {
@@ -46,7 +44,6 @@
4644
},
4745
"scripts": {
4846
"test": [
49-
"parallel-lint . --exclude vendor --no-colors",
5047
"phpunit --colors=always --verbose"
5148
]
5249
}

phpunit.xml.dist

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

tests/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
require __DIR__ . "/../vendor/autoload.php";
4+
date_default_timezone_set('UTC');

tests/src/Cards/DTO/FabricTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace B24io\Loyalty\SDK\Cards\DTO;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Ramsey\Uuid\Uuid;
9+
10+
/**
11+
* Class FabricTest
12+
*
13+
* @package B24io\Loyalty\SDK\Cards\DTO
14+
*/
15+
final class FabricTest extends TestCase
16+
{
17+
/**
18+
* @covers \B24io\Loyalty\SDK\Cards\DTO\Fabric::initFromArray
19+
*/
20+
public function testCreateCardFromArray(): void
21+
{
22+
$card = [
23+
'number' => '12345',
24+
'barcode' => '',
25+
'status' => 'active',
26+
'user' => [
27+
'user-id' => '123',
28+
],
29+
'balance' => [
30+
'amount' => '1000',
31+
'currency' => 'RUB',
32+
],
33+
'percentage' => '10.5',
34+
'created' => (new \DateTime())->format(\DATE_RFC3339),
35+
'modified' => (new \DateTime())->format(\DATE_RFC3339),
36+
'uuid' => Uuid::uuid4(),
37+
];
38+
39+
$cardDto = Fabric::initFromArray($card);
40+
$this->assertEquals($cardDto->getNumber(), $card['number']);
41+
}
42+
}

0 commit comments

Comments
 (0)