-
Notifications
You must be signed in to change notification settings - Fork 73
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
send all invitations #3039
send all invitations #3039
Conversation
Signed-off-by: dartcafe <github@dartcafe.de>
@PhrozenByte Could you have a look at the tests. I changed some methods, but the tests fail now due to changed attributes and return values. Would be a big help. |
You changed the parameters of Add For This should do the trick. Unfortunately I don't have a dev setup for the polls app anymore. |
Something I thought regarding the shareMocks, but I got stuck while trying to understand it. Thanks. I give it a try. I am not familiar with PHPUnit, so... Maybe I will learn something. ;-) The main problem is, I can't get it to work with my Windows machine, which is my default dev env. |
Signed-off-by: dartcafe <github@dartcafe.de>
@PhrozenByte I suspect the expected return is no more an array, but an object (of Did I understand your suggestions right (see last commit)? |
Ah, sorry, my bad, I missed that this logic can't work. You did everything as suggested. The problem is that our mocked We can't rely on $mockedShares = [];
$expectedShares = [];
foreach ($pollData['expectedInvitations'] ?? [] as $type => $shares) {
foreach ($shares as $userId) {
if (!in_array($userId, $pollData['initialShares'][$type] ?? [])) {
$share = $this->createShareMock($pollData['pollId'], $type, $userId);
$mockedShares[$type][$userId] = $share;
$expectedShares[] = $share;
}
}
} And then change our mocked ->willReturnCallback(function (int $pollId, string $type, string $userId = '') use ($pollData, $mockedShares): Share {
$userIdConstraint = $this->logicalOr(...$pollData['expectedShares'][$type] ?? []);
$userIdConstraint->evaluate($userId);
if (in_array($userId, $pollData['initialShares'][$type] ?? [])) {
throw new ShareAlreadyExistsException();
}
return $mockedShares[$type][$userId];
}); The suggested changes for |
Hey. Thanks. Helped me for understanding these tests. I adoped your change, see, if it runs through now. 👍 |
@PhrozenByte I am not sure, if I just created an always true condition. But I changed the input parameters to |
Switching the $initialShares = [];
$expectedShares = [];
foreach ($pollData['initialShares'] ?? [] as $type => $shares) {
foreach ($shares as $userId) {
$share = $this->createShareMock($pollData['pollId'], $type, $userId);
$initialShares[] = $share;
if (in_array($userId, $pollData['expectedShares'][$type] ?? [])) {
$expectedShares[] = $share;
}
}
} Replace On a side note, our tests (both in |
Argh I was confused, but was the source by myself. I pushed $userId to the $expectedShares array instead of the mockedShare here: 53948c9. 🙈 |
Signed-off-by: dartcafe <github@dartcafe.de>
At least there are tests. 😆 The rest of the project would need a full test suite, but I have no time for that. Since I know the structure of this app, I can test most of it manually. But one day ... who knows 😉 |
Nice, tests pass now. Great work, LGTM! 👍
I know the struggle 🙈 Creating tests isn't my favourite job either. To be honest, if it's mostly a single developer project and this developer has a complete overview over the whole project (like you do), and if the project is no library that is used by other developers (like this app), one can argue that tests don't provide a major advantage. Sure, they undoubtedly improve things and are much appreciated, but writing them takes a lot of effort and time, which is often better spent in developing new features. This only changes - but then drastically - the more developers are working on the project. But if that's not the case I don't see much of a problem when there is no test suite... |
Thanks again. I'll merge for the new beta |
resolves #1304
also refactor/maintenance: