Skip to content

Fixes and improvements in tests #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions tests/src/IntegerValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

use PHPUnit\Framework\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator on 2015 - 2016-10-05 at 20:04:03.
*/
class IntegerValidatorTest extends TestCase
{

Expand All @@ -21,7 +18,7 @@ class IntegerValidatorTest extends TestCase
*/
protected function setUp(): void
{
$this->object = new IntegerValidator(-1000, 1000, true);
$this->object = new IntegerValidator(-1000, 1000, true, true);
}

/**
Expand All @@ -32,7 +29,7 @@ protected function tearDown(): void
{
}

public function validateSuccessProvider()
public function validateSuccessProvider(): array
{
//input, expected
return [
Expand All @@ -44,20 +41,21 @@ public function validateSuccessProvider()
];
}

public function validateFailureProvider()
public function validateFailureProvider(): array
{
//input
return [
['-0x'],
['abc'],
['+xyz'],
['++30'],
[-1000], //should fail becaus of exclusiveMinimum
[-10000000],
[10000000],
['-1000000000'],
[1.4],
[-13.5]
['-0x', 'type'],
['abc', 'type'],
['+xyz', 'type'],
['++30', 'type'],
[-1000, 'minimum'], //should fail because of exclusiveMinimum
[1000, 'maximum'], //should fail because of exclusiveMaximum
[-10000000, 'minimum'],
[10000000, 'maximum'],
['-1000000000', 'minimum'],
[1.4, 'multipleOf'],
[-13.5, 'multipleOf'],
];
}

Expand All @@ -67,6 +65,8 @@ public function testConstruct()
0,
1
);

$this->assertInstanceOf('\Phramework\Validate\NumberValidator', $validator);
}

/**
Expand Down Expand Up @@ -165,15 +165,14 @@ public function testValidateSuccess($input, $expected)
/**
* @dataProvider validateFailureProvider
*/
public function testValidateFailure($input)
public function testValidateFailure($input, $failure)
{
$return = $this->object->validate($input);

$this->assertFalse($return->status);
$parameters = $return->errorObject->getParameters();

$this->markTestIncomplete(
'Test Exclusive'
);
$this->assertFalse($return->status);
$this->assertEquals($failure, $parameters[0]['failure']);
}

public function testValidateFailureMultipleOf()
Expand Down
14 changes: 12 additions & 2 deletions tests/src/ObjectValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function validateFailureProvider()
public function testConstruct()
{
$validator = new ObjectValidator();

$this->assertInstanceOf('\Phramework\Validate\ObjectValidator', $validator);
}

/**
Expand Down Expand Up @@ -656,6 +658,16 @@ public function testXVisibility()
'field1' => 'no'
]);

$this->assertEquals('no', $result->field1);
$this->assertNull($result->field2);

$result = $validator->parse((object) [
'field1' => 'yes',
'field2' => 'abcd'
]);

$this->assertEquals('yes', $result->field1);
$this->assertEquals('abcd', $result->field2);
//Expect exception
$this->expectException(
IncorrectParametersException::class
Expand All @@ -665,8 +677,6 @@ public function testXVisibility()
'field1' => 'no',
'field2' => 'abcd'
]);

$this->markTestIncomplete();
}

public function testXVisibilityOR()
Expand Down