@@ -73,16 +73,23 @@ public function getBoard($id) {
7373 $ board ->setTitle ('Board ' . $ id );
7474 return $ board ;
7575 }
76+
7677 public function getStack ($ id ) {
7778 $ stack = new Stack ();
7879 $ stack ->setId ($ id );
7980 $ stack ->setTitle ('Stack ' . $ id );
8081 return $ stack ;
8182 }
82- public function getCard ($ id ) {
83+
84+ public function getCard ($ id , $ deleted = false ) {
8385 $ card = new Card ();
8486 $ card ->setId ($ id );
8587 $ card ->setTitle ('Card ' . $ id );
88+
89+ if ($ deleted ) {
90+ $ card ->setDeletedAt (time ());
91+ }
92+
8693 return $ card ;
8794 }
8895
@@ -92,6 +99,7 @@ public function getComment($id) {
9299 $ comment ->setMessage ("fake comment " . $ id );
93100 return $ comment ;
94101 }
102+
95103 public function testExecute () {
96104 $ input = $ this ->createMock (InputInterface::class);
97105 $ input ->expects ($ this ->once ())->method ('getArgument ' )->with ('user-id ' )->willReturn ('admin ' );
@@ -101,19 +109,12 @@ public function testExecute() {
101109 $ this ->getBoard (1 ),
102110 $ this ->getBoard (2 ),
103111 ];
104- $ this ->boardService ->expects ($ this ->once ())
105- ->method ('findAll ' )
106- ->willReturn ($ boards );
107- $ this ->boardMapper ->expects ($ this ->exactly (count ($ boards )))
108- ->method ('find ' )
109- ->willReturn ($ boards [0 ]);
112+
110113 $ stacks = [
111114 $ this ->getStack (1 ),
112115 $ this ->getStack (2 )
113116 ];
114- $ this ->stackMapper ->expects ($ this ->exactly (count ($ boards )))
115- ->method ('findAll ' )
116- ->willReturn ($ stacks );
117+
117118 $ cards = [
118119 $ this ->getCard (1 ),
119120 $ this ->getCard (2 ),
@@ -125,16 +126,89 @@ public function testExecute() {
125126 $ this ->getComment (2 ),
126127 $ this ->getComment (3 ),
127128 ];
128- $ this ->commentService ->expects ($ this ->exactly (count ($ cards ) * count ($ stacks ) * count ($ boards )))->method ('list ' )->willReturn (new DataResponse ($ comments ));
129+
130+ $ this ->boardService ->expects ($ this ->once ())
131+ ->method ('findAll ' )
132+ ->willReturn ($ boards );
133+
134+ $ this ->boardMapper ->expects ($ this ->exactly (count ($ boards )))
135+ ->method ('find ' )
136+ ->willReturn ($ boards [0 ]);
137+
138+ $ this ->stackMapper ->expects ($ this ->exactly (count ($ boards )))
139+ ->method ('findAll ' )
140+ ->willReturn ($ stacks );
141+
142+ $ this ->commentService ->expects ($ this ->exactly (count ($ cards ) * count ($ stacks ) * count ($ boards )))
143+ ->method ('list ' )
144+ ->willReturn (new DataResponse ($ comments ));
145+
129146 $ this ->cardMapper ->expects ($ this ->exactly (count ($ boards ) * count ($ stacks )))
130147 ->method ('findAllByStack ' )
131148 ->willReturn ($ cards );
149+
132150 $ this ->cardMapper ->expects ($ this ->exactly (count ($ boards ) * count ($ stacks ) * count ($ cards )))
133151 ->method ('find ' )
134152 ->willReturn ($ cards [0 ]);
153+
135154 $ this ->assignedUserMapper ->expects ($ this ->exactly (count ($ boards ) * count ($ stacks ) * count ($ cards )))
136155 ->method ('findAll ' )
137156 ->willReturn ([]);
157+
158+ $ result = $ this ->invokePrivate ($ this ->userExport , 'execute ' , [$ input , $ output ]);
159+ self ::assertEquals (0 , $ result );
160+ }
161+
162+ public function testExecuteWithDeletedCard () {
163+ $ input = $ this ->createMock (InputInterface::class);
164+ $ input ->expects ($ this ->once ())->method ('getArgument ' )->with ('user-id ' )->willReturn ('admin ' );
165+ $ output = $ this ->createMock (OutputInterface::class);
166+
167+ $ boards = [
168+ $ this ->getBoard (1 ),
169+ ];
170+
171+ $ stacks = [
172+ $ this ->getStack (1 ),
173+ ];
174+
175+ $ cards = [
176+ $ this ->getCard (1 ),
177+ $ this ->getCard (2 , true ),
178+ ];
179+
180+ $ comments = [
181+ $ this ->getComment (1 ),
182+ ];
183+
184+ $ this ->boardService ->expects ($ this ->once ())
185+ ->method ('findAll ' )
186+ ->willReturn ($ boards );
187+
188+ $ this ->boardMapper ->expects ($ this ->once ())
189+ ->method ('find ' )
190+ ->willReturn ($ boards [0 ]);
191+
192+ $ this ->stackMapper ->expects ($ this ->once ())
193+ ->method ('findAll ' )
194+ ->willReturn ($ stacks );
195+
196+ $ this ->commentService ->expects ($ this ->exactly (count ($ stacks ) * count ($ boards )))
197+ ->method ('list ' )
198+ ->willReturn (new DataResponse ($ comments ));
199+
200+ $ this ->cardMapper ->expects ($ this ->once ())
201+ ->method ('findAllByStack ' )
202+ ->willReturn ($ cards );
203+
204+ $ this ->cardMapper ->expects ($ this ->once ())
205+ ->method ('find ' )
206+ ->willReturn ($ cards [0 ]);
207+
208+ $ this ->assignedUserMapper ->expects ($ this ->once ())
209+ ->method ('findAll ' )
210+ ->willReturn ([]);
211+
138212 $ result = $ this ->invokePrivate ($ this ->userExport , 'execute ' , [$ input , $ output ]);
139213 self ::assertEquals (0 , $ result );
140214 }
0 commit comments