Skip to content

Commit

Permalink
Merge pull request #51 from keboola/zajca-php8-for-v1
Browse files Browse the repository at this point in the history
PHP8 for V1
  • Loading branch information
zajca authored Feb 2, 2023
2 parents eb77f51 + 788935e commit 62398e5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 25 deletions.
11 changes: 0 additions & 11 deletions .codeclimate.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test
on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions:
- '5.6'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
steps:
- uses: actions/checkout@v2
- run: composer self-update
- run: composer install --prefer-dist --no-interaction
- run: composer ci
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"codeclimate/php-test-reporter": "^0.4",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3.2"
},
"config": {
"lock": false
},
"scripts": {
"tests": "phpunit",
"ci": [
"@composer validate --strict",
"@tests"
]
}
}
5 changes: 5 additions & 0 deletions src/CsvFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ public function validateLineBreak()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->currentRow;
Expand All @@ -428,6 +429,7 @@ public function current()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function next()
{
$this->currentRow = $this->readLine();
Expand All @@ -437,6 +439,7 @@ public function next()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->rowCounter;
Expand All @@ -445,6 +448,7 @@ public function key()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->currentRow !== false;
Expand All @@ -453,6 +457,7 @@ public function valid()
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function rewind()
{
rewind($this->getFilePointer());
Expand Down
7 changes: 5 additions & 2 deletions tests/CsvFileErrorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testException()
$csv->getHeader();
self::fail("Must throw exception.");
} catch (Exception $e) {
self::assertContains('Cannot open file', $e->getMessage());
self::assertStringContainsString('Cannot open file', $e->getMessage());
self::assertEquals(1, $e->getCode());
self::assertEquals([], $e->getContextParams());
self::assertEquals('fileNotExists', $e->getStringCode());
Expand All @@ -30,6 +30,9 @@ public function testException()
*/
public function testInvalidFileName($filename, $message)
{
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Skipped for php8 since SplFileInfo throws ValueError.');
}
$csv = new CsvFile($filename);
self::expectException(Exception::class);
self::expectExceptionMessage($message);
Expand All @@ -40,7 +43,7 @@ public function invalidFileNameProvider()
{
return [
["", 'Filename cannot be empty'],
["\0", 'fopen() expects parameter 1 to be a valid path, string given'],
// ["\0", 'fopen() expects parameter 1 to be a valid path, string given'],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CsvFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ public function validLineBreaksData()
}

/**
* @expectedException \Keboola\Csv\InvalidArgumentException
* @dataProvider invalidLineBreaksData
* @param string $file
*/
public function testInvalidLineBreak($file)
{
$this->expectException(\Keboola\Csv\InvalidArgumentException::class);
$csvFile = new CsvFile(__DIR__ . '/data/' . $file);
$csvFile->validateLineBreak();
}
Expand Down

0 comments on commit 62398e5

Please sign in to comment.