Skip to content

Commit

Permalink
Test enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Mar 26, 2019
1 parent d5155f8 commit 327bdde
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 52 deletions.
11 changes: 1 addition & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ language: php
php:
- 7.1
- 7.2

jobs:
include:
- php: 7.3.0RC1
dist: xenial
sudo: required
addons:
apt:
packages:
- libzip4
- 7.3

before_script:
- composer install
Expand Down
4 changes: 2 additions & 2 deletions tests/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testFilterMultipleRules(): void
$this->assertEquals($result, $filter->getData());
$this->assertEquals($messages, $filter->getMessages());

$this->assertInternalType('integer', $filter->getData()['age']);
$this->assertIsInt($filter->getData()['age']);
}

/**
Expand All @@ -194,7 +194,7 @@ public function testFilterMultipleRulesResultStyle(): void
$this->assertEquals($result, $r->data());
$this->assertEquals($messages, $r->messages());

$this->assertInternalType('integer', $r->data()['age']);
$this->assertIsInt($r->data()['age']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ParserTest extends TestCase
public function ruleProvider(): array
{
return [
[array( 0 => array( 0 => 'rule', 1 => 'number', 2 => array(), ), ), 'rule: number'],
[array( 0 => array( 0 => 'rule', 1 => 'number', 2 => array(), ), 1 => array( 0 => 'rule', 1 => 'numbercompare', 2 => array( 0 => '<', 1 => 25, ), ), ), 'rule: number numbercompare < 25'],
[[ 0 => [ 0 => 'rule', 1 => 'number', 2 => [], ], ], 'rule: number'],
[[ 0 => [ 0 => 'rule', 1 => 'number', 2 => [], ], 1 => [ 0 => 'rule', 1 => 'numbercompare', 2 => [ 0 => '<', 1 => 25, ], ], ], 'rule: number numbercompare < 25'],
//[[0 => [0 => 'rule', 1 => 'number', 2 => [], ], 1 => [ 0 => 'rule', 1 => 'min', 2 => [15], ], 2 => [ 0 => 'rule', 1 => 'max', 2 => [30], ], ], 'rule: number min 15 max 30'],
//[[0 => [0 => 'rule', 1 => 'number', 2 => [], ], 1 => [ 0 => 'rule', 1 => 'between', 2 => [15, 30, ], ], ],'rule: number between 15 30']
];
Expand Down
45 changes: 9 additions & 36 deletions tests/Rules/CustomRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public function testAliasWithWrongType($argument): void
(new CustomRule(
$argument,
function (string $received): bool {
if ($received === 'test') {
return true;
}
return false;
return $received === 'test';
}
));
}
Expand All @@ -74,10 +71,7 @@ public function testVoidAlias(): void
(new CustomRule(
[],
function (string $received): bool {
if ($received === 'test') {
return true;
}
return false;
return $received === 'test';
}
));
}
Expand All @@ -93,10 +87,7 @@ public function testClosureWithNoReturnType(): void
(new CustomRule(
['test'],
function (string $received) {
if ($received === 'test') {
return true;
}
return false;
return $received === 'test';
}
));
}
Expand All @@ -112,10 +103,7 @@ public function testClosureWithWrongReturnType(): void
(new CustomRule(
['test'],
function (string $received): int {
if ($received === 'test') {
return 1;
}
return 0;
return $received === 'test' ? 1: 0;
}
));
}
Expand Down Expand Up @@ -146,28 +134,16 @@ public function argumentsTypeProvider(): array
{
return [
[function (string $received): bool {
if ($received === 'test') {
return true;
}
return false;
return $received === 'test';
}, 0, []],
[function (string $received, $value): bool {
if ($received === $value) {
return true;
}
return false;
return $received === $value;
}, 1, ['string']],
[function (string $received, int $min): bool {
if ($received >= $min) {
return true;
}
return false;
return $received >= $min;
}, 1, ['number']],
[function (string $received, float $min, float $max): bool {
if ($received >= $min && $received <= $max) {
return true;
}
return false;
return $received >= $min && $received <= $max;
}, 2, ['number', 'number']]
];
}
Expand Down Expand Up @@ -199,10 +175,7 @@ public function testCustomValidate(): void
$instance = new CustomRule(
['test'],
function (string $received): bool {
if ($received === 'test') {
return true;
}
return false;
return $received === 'test';
}
);

Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/IPv4RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function validSuffixProvider(): array
*/
public function testValidCidrForAllValidSuffixes(int $suffix): void
{
$this->assertSame(false, (new IPRange())->validate('192.168.0.48', "192.168.0.48/{$suffix}"));
$this->assertFalse((new IPRange())->validate('192.168.0.48', "192.168.0.48/{$suffix}"));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/IPv6RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function validSuffixProvider(): array
*/
public function testValidCidrForAllValidSuffixes(int $suffix): void
{
$this->assertSame(false, (new IPRange())->validate('2001:abcd::0010', "2001:abcd::0010/{$suffix}"));
$this->assertFalse((new IPRange())->validate('2001:abcd::0010', "2001:abcd::0010/{$suffix}"));
}

/**
Expand Down

0 comments on commit 327bdde

Please sign in to comment.