Skip to content

Commit a293cf2

Browse files
authored
Merge pull request #2 from open-source-contributions/test_enhancement
Enhance tests for assertions and string casting
2 parents f434e63 + 9933a1d commit a293cf2

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ php:
44
- 7.1
55
- 7.2
66
- 7.3
7+
- 7.4
78

89
before_script:
910
- travis_retry composer self-update
10-
- travis_retry composer install --no-interaction --prefer-source --dev
11+
- travis_retry composer install --no-interaction --prefer-source
1112

1213
script:
1314
- vendor/bin/phpunit --coverage-clover=coverage.xml
1415

1516
after_success:
16-
- bash <(curl -s https://codecov.io/bash)
17+
- bash <(curl -s https://codecov.io/bash)

src/MonobankClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private function request(string $method, string $endpoint, Token $token = null):
9090
{
9191
$headers = [
9292
'Accept' => 'application/json',
93-
'User-Agent' => sprintf('%s MonobankPHPClient/%s', $this->client->getConfig('headers')['User-Agent'], MONOBANK_CLIENT_VERSION),
93+
'User-Agent' => sprintf('%s MonobankPHPClient/%s', $this->client->getConfig('headers')['User-Agent'] ?? '', MONOBANK_CLIENT_VERSION),
9494
];
9595

9696
if (null !== $token) {

tests/GetClientInfoTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function testSuccess()
5151

5252
$result = $client->getClientInfo();
5353

54-
$this->assertTrue(is_array($result));
55-
$this->assertTrue(is_array($result['accounts']));
56-
$this->assertTrue(1 == count($result['accounts']));
54+
$this->assertIsArray($result);
55+
$this->assertIsArray($result['accounts']);
56+
$this->assertCount(1, $result['accounts']);
5757
$this->assertEquals('Mono cat', $result['name']);
5858
}
5959

@@ -147,7 +147,7 @@ public function testCheckParams()
147147
/**
148148
* {@inheritdoc}
149149
*/
150-
public function setUp()
150+
protected function setUp(): void
151151
{
152152
parent::setUp();
153153

tests/GetExchangeRatesTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public function testSuccess()
5151

5252
$result = $client->getExchangeRates();
5353

54-
$this->assertTrue(is_array($result));
55-
$this->assertTrue(1 == count($result));
54+
$this->assertIsArray($result);
55+
$this->assertCount(1, $result);
5656
$this->assertEquals(840, $result[0]['currencyCodeA']);
5757
$this->assertEquals(980, $result[0]['currencyCodeB']);
5858
$this->assertEquals(1552392228, $result[0]['date']);
@@ -148,7 +148,7 @@ public function testCheckParams()
148148
/**
149149
* {@inheritdoc}
150150
*/
151-
public function setUp()
151+
protected function setUp(): void
152152
{
153153
parent::setUp();
154154

tests/GetPersonalStatementTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ public function testSuccess()
5656
$client = new MonobankClient($httpClient, $token);
5757
$result = $client->getPersonalStatement(new PersonalStatementRequest(new DateTime(), new DateTime()));
5858

59-
$this->assertTrue(is_array($result));
60-
$this->assertTrue(1 == count($result));
59+
$this->assertIsArray($result);
60+
$this->assertCount(1, $result);
6161
$this->assertEquals('ZuHWzqkKGVo=', $result[0]['id']);
6262
$this->assertEquals(1554466347, $result[0]['time']);
6363
$this->assertEquals('Покупка щастя', $result[0]['description']);
6464
$this->assertEquals(7997, $result[0]['mcc']);
65-
$this->assertEquals(false, $result[0]['hold']);
65+
$this->assertFalse($result[0]['hold']);
6666
$this->assertEquals(-95000, $result[0]['amount']);
6767
$this->assertEquals(-95000, $result[0]['operationAmount']);
6868
$this->assertEquals(980, $result[0]['currencyCode']);
@@ -215,7 +215,7 @@ public function testCheckParamsWithAccountID()
215215
/**
216216
* {@inheritdoc}
217217
*/
218-
public function setUp()
218+
protected function setUp(): void
219219
{
220220
parent::setUp();
221221

tests/ValueObject/AccountIDTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AccountIDTest extends TestCase
2222
*/
2323
public function testSuccess(string $id)
2424
{
25-
$this->assertEquals($id, strval(new AccountID($id)));
25+
$this->assertEquals($id, (string) (new AccountID($id)));
2626
}
2727

2828
/**

tests/ValueObject/TokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TokenTest extends TestCase
2222
*/
2323
public function testSuccess(string $token)
2424
{
25-
$this->assertEquals($token, strval(new Token($token)));
25+
$this->assertEquals($token, (string) (new Token($token)));
2626
}
2727

2828
/**

0 commit comments

Comments
 (0)