Skip to content

Commit

Permalink
Merge pull request #844 from cedric-anne/fix/php-7.4-tests
Browse files Browse the repository at this point in the history
Fix tests on PHP 7.4
  • Loading branch information
Grummfy committed Sep 28, 2020
2 parents 53ddbdf + f812af6 commit dad237d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -5,15 +5,14 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- 7.4
- nightly
cache:
directories:
- vendor
matrix:
allow_failures:
- php: nightly
- php: 7.4snapshot
notifications:
irc: "irc.freenode.org##atoum"
webhooks:
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Expand Up @@ -6,9 +6,10 @@ clone_folder: C:\projects\atoum
environment:
matrix:
- PHP_DOWNLOAD_FILE: https://windows.php.net/downloads/releases/archives/php-5.6.40-nts-Win32-VC11-x86.zip
- PHP_DOWNLOAD_FILE: https://windows.php.net/downloads/releases/latest/php-7.1-nts-Win32-VC14-x86-latest.zip
- PHP_DOWNLOAD_FILE: https://windows.php.net/downloads/releases/archives/php-7.1.33-nts-Win32-VC14-x86.zip
- PHP_DOWNLOAD_FILE: https://windows.php.net/downloads/releases/latest/php-7.2-nts-Win32-VC15-x86-latest.zip
- PHP_DOWNLOAD_FILE: https://windows.php.net/downloads/releases/latest/php-7.3-nts-Win32-VC15-x86-latest.zip
- PHP_DOWNLOAD_FILE: https://windows.php.net/downloads/releases/latest/php-7.4-nts-Win32-vc15-x86-latest.zip

notifications:
- provider: Webhook
Expand Down
2 changes: 1 addition & 1 deletion classes/mock/stream/controller.php
Expand Up @@ -40,7 +40,7 @@ public function __set($method, $value)
$this->stat = ['mode' => 33188];
$this->fopen = true;
$this->fread[1] = $value;
$this->fread[2] = false;
$this->fread[2] = '';
$this->fclose = true;
}
return $this;
Expand Down
4 changes: 4 additions & 0 deletions classes/php/tokenizer.php
Expand Up @@ -52,6 +52,10 @@ public function tokenize($string)
break;
}

if ($token === null) {
continue;
}

$this->currentIterator->append(new token($token[0], isset($token[1]) === false ? null : $token[1], isset($token[2]) === false ? null : $token[2]));
}

Expand Down
2 changes: 1 addition & 1 deletion classes/report/fields/test/event/tap.php
Expand Up @@ -77,7 +77,7 @@ public function handleEvent($event, atoum\observable $observable)

$this->testLine = 'not ok ' . ++$this->testPoint . ' - ' . trim($lastUncompleteMethod['class']) . '::' . trim($lastUncompleteMethod['method']) . '()' . PHP_EOL;

if ($lastError['class'] === $lastUncompleteMethod['class'] && $lastError['method'] === $lastUncompleteMethod['method']) {
if ($lastError && $lastError['class'] === $lastUncompleteMethod['class'] && $lastError['method'] === $lastUncompleteMethod['method']) {
$this->testLine .= '# ' . $lastError['type'] . ' : ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastError['message'])) . PHP_EOL;
} else {
$this->testLine .= '# ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastUncompleteMethod['output']) ?: 'uncomplete method') . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion tests/units/classes/mock/stream/controller.php
Expand Up @@ -253,7 +253,7 @@ public function test__set()
->then
->boolean($streamController->invoke('fopen'))->isTrue()
->string($streamController->invoke('fread'))->isEqualTo($contents)
->boolean($streamController->invoke('fread'))->isFalse()
->string($streamController->invoke('fread'))->isEqualTo('')
->boolean($streamController->invoke('fclose'))->isTrue()
->if($streamController->resetCalls()->file_put_contents = true)
->then
Expand Down
42 changes: 42 additions & 0 deletions tests/units/classes/report/fields/test/event/tap.php
Expand Up @@ -32,8 +32,50 @@ public function testHandleEvent()
->if($adapter = new atoum\test\adapter())
->and($adapter->class_exists = true)
->and($runner = new \mock\mageekguy\atoum\runner())
->and($scoreController = new mock\controller())
->and(
$scoreController->getLastErroredMethod = [
'case' => uniqid(),
'dataSetKey' => uniqid(),
'dataSetProvider' => uniqid(),
'class' => uniqid(),
'method' => uniqid(),
'file' => uniqid(),
'line' => rand(1, PHP_INT_MAX),
'type' => rand(1, E_ALL),
'message' => uniqid(),
'errorFile' => uniqid(),
'errorLine' => rand(1, PHP_INT_MAX)
]
)
->and(
$scoreController->getLastException = [
'case' => null,
'dataSetKey' => null,
'dataSetProvider' => null,
'class' => uniqid(),
'method' => uniqid(),
'file' => uniqid(),
'line' => rand(1, PHP_INT_MAX),
'value' => uniqid()
]
)
->and(
$scoreController->getLastFailAssertion = [
'case' => null,
'dataSetKey' => null,
'class' => uniqid(),
'method' => uniqid(),
'file' => uniqid(),
'line' => uniqid(),
'asserter' => uniqid(),
'fail' => uniqid()
]
)
->and($score = new \mock\mageekguy\atoum\test\score())
->and($testController = new mock\controller())
->and($testController->getTestedClassName = uniqid())
->and($testController->getScore = $score)
->and($test = new \mock\mageekguy\atoum\test($adapter))
->and($field = new testedClass())
->then
Expand Down
6 changes: 2 additions & 4 deletions tests/units/classes/writers/file.php
Expand Up @@ -116,6 +116,7 @@ public function testWrite()
trigger_error(uniqid());
return false;
})
->and($adapter->fclose = true)
->and($file = new testedClass(null, $adapter))
->and($adapter->resetCalls())
->then
Expand All @@ -137,8 +138,6 @@ public function testWrite()
->if($file = new testedClass(null, $adapter))
->and($adapter->flock = true)
->and($adapter->ftruncate = true)
->and($adapter->fclose = function () {
})
->and($adapter->fwrite = false)
->and($adapter->fflush = function () {
})
Expand Down Expand Up @@ -179,6 +178,7 @@ public function testClear()
$this
->if($adapter = new atoum\test\adapter())
->if($adapter->fopen = false)
->and($adapter->fclose = true)
->and($file = new testedClass(null, $adapter))
->and($adapter->resetCalls())
->then
Expand All @@ -190,8 +190,6 @@ public function testClear()
->if($adapter->fopen = $resource = uniqid())
->and($adapter->flock = true)
->and($adapter->ftruncate = false)
->and($adapter->fclose = function () {
})
->and($adapter->resetCalls())
->then
->exception(function () use ($file) {
Expand Down

0 comments on commit dad237d

Please sign in to comment.