Skip to content
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

Fix spec errors. #20

Merged
merged 2 commits into from
Jul 21, 2022
Merged
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"symfony/validator": "<2.5"
},
"require-dev": {
"phpspec/phpspec": "^7.2"
"phpspec/phpspec": "^7.2",
"friends-of-phpspec/phpspec-code-coverage": "^6.1"
},
"suggest": {
"symfony/property-access": "Used in MappingStep",
Expand Down
2 changes: 2 additions & 0 deletions phpspec.yml.ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ suites:
namespace: Port\Steps
psr4_prefix: Port\Steps
formatter.name: pretty
extensions:
FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension: ~
12 changes: 11 additions & 1 deletion spec/Step/ValidatorStepSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ function it_processes_an_item(Step $step, ValidatorInterface $validator, Constra
$list->count()->willReturn(0);
$validator->validate($item, Argument::type('Symfony\Component\Validator\Constraints\Collection'))->willReturn($list);

$constraint->groups = [];

$this->add('foo', $constraint)->shouldReturn($this);

$this->process(
Expand All @@ -59,6 +61,8 @@ function it_processes_and_validates_an_item(Step $step, ValidatorInterface $vali
$list->count()->willReturn(1);
$validator->validate($item, Argument::type('Symfony\Component\Validator\Constraints\Collection'))->willReturn($list);

$constraint->groups = [];

$this->add('foo', $constraint)->shouldReturn($this);

$this->process(
Expand All @@ -77,6 +81,8 @@ function it_throws_an_exception_when_option_is_not_supported(Step $step, Validat
$item = ['foo' => true];
$step->process($item, $next)->shouldNotBeCalled();

$constraint->groups = [];

$this->add('foo', $constraint)->shouldReturn($this);
$this->addOption('bar', 'baz')->shouldReturn($this);

Expand All @@ -100,6 +106,8 @@ function it_throws_an_exception_during_process_when_validation_fails(
$list = new ConstraintViolationList([$violation->getWrappedObject()]);
$validator->validate($item, Argument::type('Symfony\Component\Validator\Constraints\Collection'))->willReturn($list);

$constraint->groups = [];

$this->add('foo', $constraint)->shouldReturn($this);
$this->throwExceptions();

Expand Down Expand Up @@ -144,7 +152,7 @@ function it_validates_multiple_items_from_metadata(
}

$this->getViolations()->shouldReturn(array_fill(1, $numberOfCalls, $list));
}
}

function it_tracks_lines_when_exceptions_are_thrown_during_process(
Step $step,
Expand All @@ -161,6 +169,8 @@ function it_tracks_lines_when_exceptions_are_thrown_during_process(
};
$item = ['foo' => 10];

$constraint->groups = [];

$validator->validate($item, Argument::type('Symfony\Component\Validator\Constraints\Collection'))
->willReturn($errorList);

Expand Down
4 changes: 2 additions & 2 deletions src/Step/MappingStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public function process($item, callable $next)
}
}
} catch (NoSuchPropertyException $exception) {
throw new MappingException('Unable to map item', null, $exception);
throw new MappingException('Unable to map item', 0, $exception);
} catch (UnexpectedTypeException $exception) {
throw new MappingException('Unable to map item', null, $exception);
throw new MappingException('Unable to map item', 0, $exception);
}

return $next($item);
Expand Down