-
-
Notifications
You must be signed in to change notification settings - Fork 355
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: adds failing test #409
Conversation
I think this fails. The fourth loop matches the first test('it works if the number of items in the iterable is bigger than the number of expectations', function () {
expect([1, 2, 3, 4])
->sequence(
function ($expectation) { $expectation->toBeInt()->toEqual(1); }, // 1 - 4
function ($expectation) { $expectation->toBeInt()->toEqual(2); }, // 2
function ($expectation) { $expectation->toBeInt()->toEqual(3); }, // 3
);
expect(static::getCount())->toBe(6);
}); expect([1, 2, 3, 4, 5, 6, 7, 8])
->sequence(
function ($expectation) { $expectation->toBeInt()->toBeIn([1, 4, 7]); },
function ($expectation) { $expectation->toBeInt()->toBeIn([2, 5, 8]); },
function ($expectation) { $expectation->toBeInt()->toBeIn([3, 6]); },
);
expect(static::getCount())->toBe(16); |
As originally intended, sequence will loop back over the closures until all items in the iterable had been checked. So in the case of this failing test, there would be 8 assertions, not 6, because the first expectation in the sequence would be called twice (for the first and last item in the sequence). |
@nunomaduro another error seems to rise in I think Why did you need to use
otherwise the return type on line 91 should not be defined at all (return seems to be assumed to be this breaks the pipeline in #405 also, but I'm not fixing it there, maybe we should do it here? |
@fabio-ivona fixed. @lukeraymonddowning "because the first expectation in the sequence would be called twice (for the first and last item in the sequence)." This seems weird to me. I would expect the first expectation called once, on the first element of the iterable. There is a reasoning about this behaviour ? |
The reasoning was to match how sequence works in Laravel factories, which is loosely what this was based on. |
Thank you @lukeraymonddowning |
cc @lukeraymonddowning is this failing test normal?