@@ -92,9 +92,10 @@ public function testCreateWithWrongCompetitionState() {
92
92
/**
93
93
* Simulate a user updating the sosi state (kdb remains)
94
94
*/
95
- public function testUpdateAllowedForWineAdministrator () {
95
+ public function testUpdateNotAllowedForWineAdministrator () {
96
96
$ user = $ this ->getUserMock ();
97
97
$ wine = Mockery::mock (Wine::class);
98
+ $ competition = Mockery::mock (Competition::class);
98
99
$ data = [
99
100
'id ' => 23 ,
100
101
'kdb ' => true ,
@@ -106,7 +107,40 @@ public function testUpdateAllowedForWineAdministrator() {
106
107
$ wine ->shouldReceive ('getAttribute ' )
107
108
->with ('sosi ' )
108
109
->andReturn (false );
109
- $ wine ->shouldReceive ('administrates ' )
110
+ $ wine ->shouldReceive ('getAttribute ' )
111
+ ->with ('competition ' )
112
+ ->andReturn ($ competition );
113
+ $ competition ->shouldReceive ('administrates ' )
114
+ ->with ($ user )
115
+ ->andReturn (false );
116
+
117
+ $ allowed = $ this ->abilities ->update ($ user , $ wine , $ data );
118
+
119
+ $ this ->assertFalse ($ allowed );
120
+ }
121
+
122
+ /**
123
+ * Simulate a user updating the sosi state (kdb remains)
124
+ */
125
+ public function testUpdateAllowedForCompetitionAdministrator () {
126
+ $ user = $ this ->getUserMock ();
127
+ $ wine = Mockery::mock (Wine::class);
128
+ $ competition = Mockery::mock (Competition::class);
129
+ $ data = [
130
+ 'id ' => 23 ,
131
+ 'kdb ' => true ,
132
+ 'sosi ' => true ,
133
+ ];
134
+ $ wine ->shouldReceive ('getAttribute ' )
135
+ ->with ('kdb ' )
136
+ ->andReturn (true );
137
+ $ wine ->shouldReceive ('getAttribute ' )
138
+ ->with ('sosi ' )
139
+ ->andReturn (false );
140
+ $ wine ->shouldReceive ('getAttribute ' )
141
+ ->with ('competition ' )
142
+ ->andReturn ($ competition );
143
+ $ competition ->shouldReceive ('administrates ' )
110
144
->with ($ user )
111
145
->andReturn (true );
112
146
0 commit comments