Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Oct 10, 2018
1 parent 7a32101 commit fcd121e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Wine/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function update(Wine $wine, array $data) {
}
// Validate and update approval nr only during enrollment
// TODO: refactor this logic into better permission/state checks
if ((isset($data['approvalnr']) || is_null($data['approvalnr'])) && $competitionState->id > CompetitionState::STATE_ENROLLMENT) {
if (array_key_exists('approvalnr', $data) && $competitionState->id > CompetitionState::STATE_ENROLLMENT) {
unset($data['approvalnr']);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/Wine/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ public function testUpdate() {
public function testUpdateWithValidationError() {
$user = Mockery::mock(User::class);
$competition = Mockery::mock(Competition::class);
$competitionState = Mockery::mock(CompetitionState::class);
$wine = Mockery::mock(Wine::class);
$data = [
'chosen' => true,
];
$wine->shouldReceive('getAttribute')
->with('competition')
->andReturn($competition);
$competition->shouldReceive('getAttribute')
->with('competitionState')
->andReturn($competitionState);
Auth::shouldReceive('user')
->andReturn($user);
$validator = Mockery::mock(WineValidator::class);
Expand Down

0 comments on commit fcd121e

Please sign in to comment.