Skip to content

Commit

Permalink
Dropped PHP < 5.6 support [Closes nette#364] (nette#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
milo committed Jul 30, 2017
1 parent df5e87f commit 1dfe98a
Show file tree
Hide file tree
Showing 42 changed files with 156 additions and 210 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
Expand Down
22 changes: 0 additions & 22 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@ init:
- SET ANSICON=121x90 (121x90)

install:
# Install PHP 5.4
- IF EXIST c:\php\54 (SET PHP=0) ELSE (SET PHP=1)
- IF %PHP%==1 mkdir c:\php\54
- IF %PHP%==1 cd c:\php\54
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.4.44-Win32-VC9-x86.zip
- IF %PHP%==1 7z x php-5.4.44-Win32-VC9-x86.zip >nul
- IF %PHP%==1 del /Q *.zip

# Install PHP 5.5
- IF EXIST c:\php\55 (SET PHP=0) ELSE (SET PHP=1)
- IF %PHP%==1 mkdir c:\php\55
- IF %PHP%==1 cd c:\php\55
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.5.32-Win32-VC11-x86.zip
- IF %PHP%==1 7z x php-5.5.32-Win32-VC11-x86.zip >nul
- IF %PHP%==1 del /Q *.zip

# Install PHP 5.6
- IF EXIST c:\php\56 (SET PHP=0) ELSE (SET PHP=1)
- IF %PHP%==1 mkdir c:\php\56
Expand Down Expand Up @@ -51,12 +35,6 @@ install:
- cd c:\projects\tester

test_script:
- c:\php\54\php src\tester tests -s -p c:\php\54\php
- c:\php\54\php src\tester tests -s -p c:\php\54\php-cgi

- c:\php\55\php src\tester tests -s -p c:\php\55\php
- c:\php\55\php src\tester tests -s -p c:\php\55\php-cgi

- c:\php\56\php src\tester tests -s -p c:\php\56\php
- c:\php\56\php src\tester tests -s -p c:\php\56\php-cgi

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=5.4.0"
"php": ">=5.6.0"
},
"autoload": {
"classmap": ["src/"]
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ or use a Composer:
php composer.phar require --dev nette/tester
```

Nette Tester requires PHP 5.4.0 or later. Collecting and processing
Nette Tester requires PHP 5.6.0 or later. Collecting and processing
code coverage information depends on Xdebug.


Expand Down Expand Up @@ -66,7 +66,7 @@ Now we run tests from command-line using the `tester` command:
|_ _/ __)( __/_ _/ __)| _ )
|_| \___ /___) |_| \___ |_|_\ v2.0.x
PHP 5.4.0 | "php-cgi" -n | 8 threads
PHP 5.6.0 | "php-cgi" -n | 8 threads
.
OK (1 tests, 0 skipped, 0.0 seconds)
```
Expand Down
3 changes: 1 addition & 2 deletions src/Framework/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public static function testQuery($input, $query)
static $replaces = ['' => '=', '=>' => '>=', '=<' => '<='];
$tokens = preg_split('#\s+#', $input);
preg_match_all('#\s*,?\s*(<=|=<|<|==|=|!=|<>|>=|=>|>)?\s*([^\s,]+)#A', $query, $queryParts, PREG_SET_ORDER);
foreach ($queryParts as $queryPart) {
list(, $operator, $operand) = $queryPart;
foreach ($queryParts as list(, $operator, $operand)) {
$operator = isset($replaces[$operator]) ? $replaces[$operator] : $operator;
$token = (string) array_shift($tokens);
$res = preg_match('#^[0-9.]+\z#', $token)
Expand Down
8 changes: 4 additions & 4 deletions src/Framework/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ public static function color($color = '', $s = null)
null => '0',
];
$c = explode('/', $color);
return "\033["
. str_replace(';', "m\033[", $colors[$c[0]] . (empty($c[1]) ? '' : ';4' . substr($colors[$c[1]], -1)))
. 'm' . $s . ($s === null ? '' : "\033[0m");
return "\e["
. str_replace(';', "m\e[", $colors[$c[0]] . (empty($c[1]) ? '' : ';4' . substr($colors[$c[1]], -1)))
. 'm' . $s . ($s === null ? '' : "\e[0m");
}


public static function removeColors($s)
{
return preg_replace('#\033\[[\d;]+m#', '', $s);
return preg_replace('#\e\[[\d;]+m#', '', $s);
}
}
2 changes: 1 addition & 1 deletion src/Framework/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function setupErrors()
});

register_shutdown_function(function () {
Assert::$onFailure = [__CLASS__, 'handleException']; // note that Runner is unable to catch this errors in CLI & PHP 5.4.0 - 5.4.6 due PHP bug #62725
Assert::$onFailure = [__CLASS__, 'handleException'];

$error = error_get_last();
register_shutdown_function(function () use ($error) {
Expand Down
2 changes: 1 addition & 1 deletion src/Runner/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
'PHP temporary directory' => $info->tempDir == '' ? '(empty)' : $info->tempDir,
'Loaded extensions' => count($info->extensions) ? implode(', ', $info->extensions) : '(none)',
] as $title => $value) {
echo "\033[1;32m$title\033[0m:\n$value\n\n";
echo "\e[1;32m$title\e[0m:\n$value\n\n";
}
2 changes: 1 addition & 1 deletion tests/CodeCoverage/Collector.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Assert::true(CodeCoverage\Collector::isStarted());

Assert::exception(function () use ($outputFile) {
CodeCoverage\Collector::start($outputFile);
}, 'LogicException', 'Code coverage collector has been already started.');
}, LogicException::class, 'Code coverage collector has been already started.');

$content = file_get_contents($outputFile);
Assert::same('', $content);
Expand Down
26 changes: 12 additions & 14 deletions tests/CodeCoverage/PhpParser.parse.edge.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ Assert::equal([
], $parsed->classes['C']->methods);


if (PHP_VERSION_ID >= 50500) {
// The '::CLASS' construct
Assert::equal((object) [
'linesOfCode' => 1,
'linesOfComments' => 0,
'functions' => [],
'classes' => [
'A' => (object) ['start' => 1, 'end' => 1, 'methods' => []],
'B' => (object) ['start' => 1, 'end' => 1, 'methods' => []],
],
'traits' => [],
'interfaces' => [],
], $parser->parse('<?php class A {} echo A::CLASS; class B {}'));
}
// The '::class' construct
Assert::equal((object) [
'linesOfCode' => 1,
'linesOfComments' => 0,
'functions' => [],
'classes' => [
'A' => (object) ['start' => 1, 'end' => 1, 'methods' => []],
'B' => (object) ['start' => 1, 'end' => 1, 'methods' => []],
],
'traits' => [],
'interfaces' => [],
], $parser->parse('<?php class A {} echo A::class; class B {}'));
24 changes: 10 additions & 14 deletions tests/Framework/Assert.contains.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,39 @@ $notContains = [
['1', [true]],
];

foreach ($contains as $case) {
list($expected, $value) = $case;

foreach ($contains as list($expected, $value)) {
Assert::contains($expected, $value);

Assert::exception(function () use ($expected, $value) {
Assert::notContains($expected, $value);
}, 'Tester\AssertException', '%a% should not contain %a%');
}, Tester\AssertException::class, '%a% should not contain %a%');
}

foreach ($notContains as $case) {
list($expected, $value) = $case;

Assert::notContains($case[0], $case[1]);
foreach ($notContains as list($expected, $value)) {
Assert::notContains($expected, $value);

Assert::exception(function () use ($expected, $value) {
Assert::contains($expected, $value);
}, 'Tester\AssertException', '%a% should contain %a%');
}, Tester\AssertException::class, '%a% should contain %a%');
}


Assert::exception(function () {
Assert::contains(1, 1);
}, 'Tester\AssertException', '1 should be string or array');
}, Tester\AssertException::class, '1 should be string or array');

Assert::exception(function () {
Assert::notContains(1, 1);
}, 'Tester\AssertException', '1 should be string or array');
}, Tester\AssertException::class, '1 should be string or array');

Assert::exception(function () {
Assert::notContains('', '1');
}, 'Tester\AssertException', "'1' should not contain ''");
}, Tester\AssertException::class, "'1' should not contain ''");

Assert::exception(function () {
Assert::contains('a', '1', 'Custom description');
}, 'Tester\AssertException', "Custom description: '1' should contain 'a'");
}, Tester\AssertException::class, "Custom description: '1' should contain 'a'");

Assert::exception(function () {
Assert::notContains('1', '1', 'Custom description');
}, 'Tester\AssertException', "Custom description: '1' should not contain '1'");
}, Tester\AssertException::class, "Custom description: '1' should not contain '1'");
12 changes: 6 additions & 6 deletions tests/Framework/Assert.count.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ Assert::equal(4, Assert::$counter);
// test wrong count
Assert::exception(function () {
Assert::count(1, [1, 2, 3]);
}, 'Tester\AssertException', 'Count 3 should be 1');
}, Tester\AssertException::class, 'Count 3 should be 1');

// test not countable values
Assert::exception(function () {
Assert::count(1, null);
}, 'Tester\AssertException', 'NULL should be array or countable object');
}, Tester\AssertException::class, 'NULL should be array or countable object');

Assert::exception(function () {
Assert::count(1, 1);
}, 'Tester\AssertException', '1 should be array or countable object');
}, Tester\AssertException::class, '1 should be array or countable object');

Assert::exception(function () {
Assert::count(1, 'lorem ipsum');
}, 'Tester\AssertException', '\'lorem ipsum\' should be array or countable object');
}, Tester\AssertException::class, '\'lorem ipsum\' should be array or countable object');

Assert::exception(function () {
Assert::count(1, new \Exception('lorem ipsum'));
}, 'Tester\AssertException', 'Exception Exception: lorem ipsum should be array or countable object');
}, Tester\AssertException::class, 'Exception Exception: lorem ipsum should be array or countable object');

Assert::exception(function () {
Assert::count(1, [1, 2, 3], 'Custom description');
}, 'Tester\AssertException', 'Custom description: Count 3 should be 1');
}, Tester\AssertException::class, 'Custom description: Count 3 should be 1');
24 changes: 9 additions & 15 deletions tests/Framework/Assert.equal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,37 @@ $notEquals = [
[1, 1.0],
[INF, -INF],
[['a', 'b'], ['b', 'a']],
[NAN, NAN],
];

if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$notEquals[] = [NAN, NAN];
}


foreach ($equals as $case) {
list($expected, $value) = $case;

foreach ($equals as list($expected, $value)) {
Assert::equal($expected, $value);

Assert::exception(function () use ($expected, $value) {
Assert::notEqual($expected, $value);
}, 'Tester\AssertException', '%a% should not be equal to %a%');
}, Tester\AssertException::class, '%a% should not be equal to %a%');
}

foreach ($notEquals as $case) {
list($expected, $value) = $case;

Assert::notEqual($case[0], $case[1]);
foreach ($notEquals as list($expected, $value)) {
Assert::notEqual($expected, $value);

Assert::exception(function () use ($expected, $value) {
Assert::equal($expected, $value);
}, 'Tester\AssertException', '%a% should be equal to %a%');
}, Tester\AssertException::class, '%a% should be equal to %a%');
}

Assert::exception(function () {
$rec = [];
$rec[] = &$rec;
Assert::equal($rec, $rec);
}, 'Exception', 'Nesting level too deep or recursive dependency.');
}, Exception::class, 'Nesting level too deep or recursive dependency.');

Assert::exception(function () {
Assert::equal(true, false, 'Custom description');
}, 'Tester\AssertException', 'Custom description: %a% should be equal to %a%');
}, Tester\AssertException::class, 'Custom description: %a% should be equal to %a%');

Assert::exception(function () {
Assert::notEqual(true, true, 'Custom description');
}, 'Tester\AssertException', 'Custom description: %a% should not be equal to %a%');
}, Tester\AssertException::class, 'Custom description: %a% should not be equal to %a%');
16 changes: 8 additions & 8 deletions tests/Framework/Assert.error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ Assert::error(function () {
Assert::exception(function () {
Assert::error(function () {
}, E_NOTICE);
}, 'Tester\AssertException', 'Error was expected, but was not generated');
}, Tester\AssertException::class, 'Error was expected, but was not generated');

Assert::exception(function () {
Assert::error(function () {
$a++;
}, E_WARNING);
}, 'Tester\AssertException', 'E_WARNING was expected, but E_NOTICE (Undefined variable: a) was generated in file %a% on line %d%');
}, Tester\AssertException::class, 'E_WARNING was expected, but E_NOTICE (Undefined variable: a) was generated in file %a% on line %d%');

Assert::exception(function () {
Assert::error(function () {
$a++;
}, E_NOTICE, 'Abc');
}, 'Tester\AssertException', "E_NOTICE with a message matching 'Abc' was expected but got 'Undefined variable: a'");
}, Tester\AssertException::class, "E_NOTICE with a message matching 'Abc' was expected but got 'Undefined variable: a'");

Assert::exception(function () {
Assert::error(function () {
$a++;
$b++;
}, E_NOTICE, 'Undefined variable: a');
}, 'Tester\AssertException', 'Generated more errors than expected: E_NOTICE (Undefined variable: b) was generated in file %a% on line %d%');
}, Tester\AssertException::class, 'Generated more errors than expected: E_NOTICE (Undefined variable: b) was generated in file %a% on line %d%');

Assert::exception(function () {
Assert::error(function () {
Expand All @@ -57,21 +57,21 @@ Assert::exception(function () {
[E_NOTICE, 'Undefined variable: a'],
[E_NOTICE, 'Undefined variable: b'],
]);
}, 'Tester\AssertException', 'Error was expected, but was not generated');
}, Tester\AssertException::class, 'Error was expected, but was not generated');



$e = Assert::error(function () {
throw new Exception;
}, 'Exception');
}, Exception::class);

Assert::true($e instanceof Exception);

Assert::error(function () {
throw new Exception('Text 123');
}, 'Exception', 'Text %d%');
}, Exception::class, 'Text %d%');


Assert::exception(function () {
Assert::error(function () {}, null);
}, 'Exception', 'Error type must be E_* constant.');
}, Exception::class, 'Error type must be E_* constant.');
Loading

0 comments on commit 1dfe98a

Please sign in to comment.