Skip to content

Commit f9222a9

Browse files
authored
Merge pull request #9 from geekwright/php8testing
Add latest version to unit testing
2 parents 5aed20e + 4c30961 commit f9222a9

15 files changed

+24
-102
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ language: php
33
php:
44
- 7.1
55
- 7.2
6+
- 7.3
7+
- 7.4
8+
- 8.0
69
- nightly
710

811
matrix:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require-dev": {
2424
"smarty/smarty": "^3.1",
25-
"phpunit/phpunit": "^6.5|^7.0"
25+
"phpunit/phpunit": "^7.0|^8.0"
2626
},
2727
"autoload": {
2828
"psr-4": {

src/PoFile.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function addEntry(PoEntry $entry, bool $replace = true): bool
165165
{
166166
$key = $this->createKeyFromEntry($entry);
167167

168-
// some entires, such as obsolete entries, have no key
168+
// some entries, such as obsolete entries, have no key
169169
// for some uses, these are dead weight - need better strategy for that case
170170
if (empty($key)) {
171171
$this->unkeyedEntries[] = $entry;
@@ -174,10 +174,10 @@ public function addEntry(PoEntry $entry, bool $replace = true): bool
174174

175175
if (isset($this->entries[$key]) && !$replace) {
176176
return false;
177-
} else {
178-
$this->entries[$key] = $entry;
179-
return true;
180177
}
178+
179+
$this->entries[$key] = $entry;
180+
return true;
181181
}
182182

183183
/**

src/PoHeader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ public function setHeader(string $key, string $value): void
105105
{
106106
$this->buildStructuredHeaders();
107107
$lkey = strtolower($key);
108+
$newHeader = array('key' => $key, 'value' => $value);
108109
if (isset($this->structuredHeaders[$lkey])) {
109-
$this->structuredHeaders[$lkey]['value'] = $value;
110-
} else {
111-
$newHeader = array('key' => $key, 'value' => $value);
112-
$this->structuredHeaders[$lkey] = $newHeader;
110+
$newHeader = $this->structuredHeaders[$lkey];
111+
$newHeader['value'] = $value;
113112
}
113+
$this->structuredHeaders[$lkey] = $newHeader;
114114
$this->storeStructuredHeader();
115115
}
116116

src/PoInitAbstract.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ public function addPgettextTags($tags): void
172172
*/
173173
public function msginitFile(string $filename): PoFile
174174
{
175-
if (!is_readable($filename)) {
176-
$source = false;
177-
} else {
175+
$source = false;
176+
if (is_readable($filename)) {
178177
$source = file_get_contents($filename);
179178
}
180179
if (false===$source) {

tests/Exceptions/FileNotReadableExceptionTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ class FileNotReadableExceptionTest extends \PHPUnit\Framework\TestCase
1515
* Sets up the fixture, for example, opens a network connection.
1616
* This method is called before a test is executed.
1717
*/
18-
protected function setUp()
18+
protected function setUp():void
1919
{
2020
$this->object = new FileNotReadableException;
2121
}
2222

23-
/**
24-
* Tears down the fixture, for example, closes a network connection.
25-
* This method is called after a test is executed.
26-
*/
27-
protected function tearDown()
28-
{
29-
}
30-
3123
public function testContracts()
3224
{
3325
$this->assertInstanceOf('\Geekwright\Po\Exceptions\FileNotReadableException', $this->object);

tests/Exceptions/FileNotWritableExceptionTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ class FileNotWritableExceptionTest extends \PHPUnit\Framework\TestCase
1515
* Sets up the fixture, for example, opens a network connection.
1616
* This method is called before a test is executed.
1717
*/
18-
protected function setUp()
18+
protected function setUp():void
1919
{
2020
$this->object = new FileNotWritableException;
2121
}
2222

23-
/**
24-
* Tears down the fixture, for example, closes a network connection.
25-
* This method is called after a test is executed.
26-
*/
27-
protected function tearDown()
28-
{
29-
}
30-
3123
public function testContracts()
3224
{
3325
$this->assertInstanceOf('\Geekwright\Po\Exceptions\FileNotWritableException', $this->object);

tests/Exceptions/UnrecognizedInputExceptionTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ class UnrecognizedInputExceptionTest extends \PHPUnit\Framework\TestCase
1515
* Sets up the fixture, for example, opens a network connection.
1616
* This method is called before a test is executed.
1717
*/
18-
protected function setUp()
18+
protected function setUp():void
1919
{
2020
$this->object = new UnrecognizedInputException;
2121
}
2222

23-
/**
24-
* Tears down the fixture, for example, closes a network connection.
25-
* This method is called after a test is executed.
26-
*/
27-
protected function tearDown()
28-
{
29-
}
30-
3123
public function testContracts()
3224
{
3325
$this->assertInstanceOf('\Geekwright\Po\Exceptions\UnrecognizedInputException', $this->object);

tests/PoEntryTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,11 @@ class PoEntryTest extends \PHPUnit\Framework\TestCase
1212
* Sets up the fixture, for example, opens a network connection.
1313
* This method is called before a test is executed.
1414
*/
15-
protected function setUp()
15+
protected function setUp():void
1616
{
1717
$this->object = new PoEntry;
1818
}
1919

20-
/**
21-
* Tears down the fixture, for example, closes a network connection.
22-
* This method is called after a test is executed.
23-
*/
24-
protected function tearDown()
25-
{
26-
}
27-
2820
public function testAddGetSet()
2921
{
3022
$entry = new PoEntry;

tests/PoFileTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,11 @@ class PoFileTest extends \PHPUnit\Framework\TestCase
1212
* Sets up the fixture, for example, opens a network connection.
1313
* This method is called before a test is executed.
1414
*/
15-
protected function setUp()
15+
protected function setUp():void
1616
{
1717
$this->object = new PoFile;
1818
}
1919

20-
/**
21-
* Tears down the fixture, for example, closes a network connection.
22-
* This method is called after a test is executed.
23-
*/
24-
protected function tearDown()
25-
{
26-
}
27-
2820
public function testCreateKey()
2921
{
3022
$msgid = 'message';

0 commit comments

Comments
 (0)