Skip to content

Commit 528c054

Browse files
authored
[#11] Add error object (#21)
* [#11] Add error object * [#11] Remove composer lock again
1 parent e96891e commit 528c054

40 files changed

+292
-390
lines changed

spec/Check/CountCheckSpec.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ function it_implements_type_interface(TypeInterface $child)
2727
function it_returns_a_result_on_invalid_child_check(TypeInterface $child, ResultInterface $result)
2828
{
2929
$result->isValid()->willReturn(false);
30-
$child->check(Argument::any())->willReturn($result);
30+
$child->check('', Argument::any())->willReturn($result);
3131

3232
$this->beConstructedWith($child, 1);
3333

34-
$this->check([])->shouldHaveType(ResultInterface::class);
34+
$this->check('', [])->shouldHaveType(ResultInterface::class);
3535
}
3636

3737
function it_returns_a_result_on_check(TypeInterface $child, ResultInterface $result)
3838
{
3939
$result->isValid()->willReturn(true);
40-
$child->check(Argument::any())->willReturn($result);
40+
$child->check('', Argument::any())->willReturn($result);
4141

4242
$this->beConstructedWith($child, 1);
4343

44-
$this->check([3])->shouldHaveType(ResultInterface::class);
44+
$this->check('', [3])->shouldHaveType(ResultInterface::class);
4545
}
4646
}

spec/Check/NumericRangeCheckSpec.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ function it_implements_type_interface(TypeInterface $child)
2828
function it_returns_a_result_on_invalid_child_check(TypeInterface $child, ResultInterface $result)
2929
{
3030
$result->isValid()->willReturn(false);
31-
$child->check(Argument::any())->willReturn($result);
31+
$child->check('', Argument::any())->willReturn($result);
3232

3333
$this->beConstructedWith($child, 0, 1);
3434

35-
$this->check(Argument::any())->shouldHaveType(ResultInterface::class);
35+
$this->check('', Argument::any())->shouldHaveType(ResultInterface::class);
3636
}
3737

3838
function it_returns_a_result_on_check(TypeInterface $child, ResultInterface $result)
3939
{
4040
$result->isValid()->willReturn(true);
41-
$child->check(Argument::any())->willReturn($result);
41+
$child->check('', Argument::any())->willReturn($result);
4242

4343
$this->beConstructedWith($child, 0, 1);
4444

45-
$this->check(0)->shouldHaveType(ResultInterface::class);
45+
$this->check('', 0)->shouldHaveType(ResultInterface::class);
4646
}
4747
}

spec/CheckerSpec.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ function it_is_initializable()
1414
$this->shouldHaveType(Checker::class);
1515
}
1616

17-
function it_accepts_a_type_and_an_array_as_parameter_for_fulfills(TypeInterface $type)
17+
function it_accepts_a_type_and_an_array_as_parameter_for_fulfills(TypeInterface $type, ResultInterface $result)
1818
{
19+
$type->check('', [])->willReturn($result);
1920
$this->fulfills([], $type);
2021
}
2122

2223
function it_returns_the_result_of_the_type_in_fulfills(TypeInterface $type, ResultInterface $result)
2324
{
24-
$type->check([])->willReturn($result);
25+
$type->check('', [])->willReturn($result);
2526
$this->fulfills([], $type)->shouldBe($result);
2627
}
2728
}

spec/ResultSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function it_will_return_is_invalid_if_it_was_set_in_constructor()
2828

2929
function it_will_return_an_empty_array_if_no_error_list_is_given()
3030
{
31-
$this->beConstructedWith(true);
31+
$this->beConstructedWith(true, []);
3232
$this->getErrors()->shouldHaveCount(0);
3333
}
3434
}

spec/Type/AnyTypeSpec.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ function it_is_initializable()
1515

1616
function it_should_return_valid_for_null()
1717
{
18-
$this->check(null)->isValid()->shouldBe(true);
18+
$this->check('', null)->isValid()->shouldBe(true);
1919
}
2020

2121
function it_should_return_empty_errors_for_null()
2222
{
23-
$this->check(null)->getErrors()->shouldHaveCount(0);
23+
$this->check('', null)->getErrors()->shouldHaveCount(0);
2424
}
2525

2626
function it_should_return_valid_for_all_values()
2727
{
28-
$this->check(true)->isValid()->shouldBe(true);
29-
$this->check("foo")->isValid()->shouldBe(true);
30-
$this->check(13)->isValid()->shouldBe(true);
28+
$this->check('', true)->isValid()->shouldBe(true);
29+
$this->check('', "foo")->isValid()->shouldBe(true);
30+
$this->check('', 13)->isValid()->shouldBe(true);
3131
}
3232

3333
function it_should_return_empty_errors_for_all_values()
3434
{
35-
$this->check(true)->getErrors()->shouldHaveCount(0);
36-
$this->check("foo")->getErrors()->shouldHaveCount(0);
37-
$this->check(13)->getErrors()->shouldHaveCount(0);
35+
$this->check('', true)->getErrors()->shouldHaveCount(0);
36+
$this->check('', "foo")->getErrors()->shouldHaveCount(0);
37+
$this->check('', 13)->getErrors()->shouldHaveCount(0);
3838
}
3939
}

spec/Type/BoolTypeSpec.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ function it_is_initializable()
1515

1616
function it_should_return_valid_for_bool()
1717
{
18-
$this->check(true)->isValid()->shouldBe(true);
19-
$this->check(false)->isValid()->shouldBe(true);
18+
$this->check('', true)->isValid()->shouldBe(true);
19+
$this->check('', false)->isValid()->shouldBe(true);
2020
}
2121

2222
function it_should_return_invalid_for_others()
2323
{
24-
$this->check(null)->isValid()->shouldBe(false);
25-
$this->check("foo")->isValid()->shouldBe(false);
26-
$this->check([])->isValid()->shouldBe(false);
27-
$this->check(1)->isValid()->shouldBe(false);
28-
$this->check(1.0)->isValid()->shouldBe(false);
24+
$this->check('', null)->isValid()->shouldBe(false);
25+
$this->check('', "foo")->isValid()->shouldBe(false);
26+
$this->check('', [])->isValid()->shouldBe(false);
27+
$this->check('', 1)->isValid()->shouldBe(false);
28+
$this->check('', 1.0)->isValid()->shouldBe(false);
2929
}
3030
}

spec/Type/DatetimeTypeSpec.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ function it_should_return_valid_for_correct_values()
1818
{
1919
$this->beConstructedWith('d-m-Y h:m:s', 'Europe/Berlin');
2020

21-
$this->check('12-12-2012 12:12:10')->isValid()->shouldBe(true);
21+
$this->check('', '12-12-2012 12:12:10')->isValid()->shouldBe(true);
2222
}
2323

2424
function it_should_return_invalid_for_others()
2525
{
2626
$this->beConstructedWith('d-m-Y h:m:s', 'Europe/Berlin');
2727

28-
$this->check(null)->isValid()->shouldBe(false);
29-
$this->check('foo')->isValid()->shouldBe(false);
30-
$this->check([])->isValid()->shouldBe(false);
31-
$this->check(1.234)->isValid()->shouldBe(false);
32-
$this->check(true)->isValid()->shouldBe(false);
33-
$this->check(false)->isValid()->shouldBe(false);
28+
$this->check('', null)->isValid()->shouldBe(false);
29+
$this->check('', 'foo')->isValid()->shouldBe(false);
30+
$this->check('', [])->isValid()->shouldBe(false);
31+
$this->check('', 1.234)->isValid()->shouldBe(false);
32+
$this->check('', true)->isValid()->shouldBe(false);
33+
$this->check('', false)->isValid()->shouldBe(false);
3434
}
3535
}

spec/Type/EnumTypeSpec.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ function it_is_valid_for_all_allowed_values()
1818
{
1919
$this->beConstructedWith(['test', 1, null]);
2020

21-
$this->check('test')->isValid()->shouldBe(true);
22-
$this->check(1)->isValid()->shouldBe(true);
23-
$this->check(null)->isValid()->shouldBe(true);
21+
$this->check('', 'test')->isValid()->shouldBe(true);
22+
$this->check('', 1)->isValid()->shouldBe(true);
23+
$this->check('', null)->isValid()->shouldBe(true);
2424
}
2525

2626
function it_is_invalid_for_not_allowed_values()
2727
{
2828
$this->beConstructedWith(['test', 1, null]);
29-
30-
$this->check('array')->isValid()->shouldBe(false);
31-
$this->check(100)->isValid()->shouldBe(false);
32-
$this->check(1.5)->isValid()->shouldBe(false);
33-
$this->check(['test'])->isValid()->shouldBe(false);
29+
30+
$this->check('', 'array')->isValid()->shouldBe(false);
31+
$this->check('', 100)->isValid()->shouldBe(false);
32+
$this->check('', 1.5)->isValid()->shouldBe(false);
33+
$this->check('', ['test'])->isValid()->shouldBe(false);
3434
}
3535
}

spec/Type/ExactValueTypeSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ function it_is_initializable()
1717
function it_is_valid_for_null_if_null_is_the_value()
1818
{
1919
$this->beConstructedWith(null);
20-
$this->check(null)->isValid()->shouldBe(true);
20+
$this->check('', null)->isValid()->shouldBe(true);
2121
}
2222
}

spec/Type/FloatTypeSpec.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ function it_is_initializable()
1414

1515
function it_should_return_valid_for_floats()
1616
{
17-
$this->check(0.0)->isValid()->shouldBe(true);
18-
$this->check(1.1)->isValid()->shouldBe(true);
19-
$this->check(2.0)->isValid()->shouldBe(true);
20-
$this->check(-144.2)->isValid()->shouldBe(true);
17+
$this->check('', 0.0)->isValid()->shouldBe(true);
18+
$this->check('', 1.1)->isValid()->shouldBe(true);
19+
$this->check('', 2.0)->isValid()->shouldBe(true);
20+
$this->check('', -144.2)->isValid()->shouldBe(true);
2121
}
2222

2323
function it_should_return_invalid_for_others()
2424
{
25-
$this->check(null)->isValid()->shouldBe(false);
26-
$this->check("foo")->isValid()->shouldBe(false);
27-
$this->check([])->isValid()->shouldBe(false);
28-
$this->check(1)->isValid()->shouldBe(false);
29-
$this->check(true)->isValid()->shouldBe(false);
30-
$this->check(false)->isValid()->shouldBe(false);
25+
$this->check('', null)->isValid()->shouldBe(false);
26+
$this->check('', "foo")->isValid()->shouldBe(false);
27+
$this->check('', [])->isValid()->shouldBe(false);
28+
$this->check('', 1)->isValid()->shouldBe(false);
29+
$this->check('', true)->isValid()->shouldBe(false);
30+
$this->check('', false)->isValid()->shouldBe(false);
3131
}
3232
}

0 commit comments

Comments
 (0)