22
33# Laravel Testing Tools
44
5- [ <img src =" https://user-images.githubusercontent.com/1286821/43083932-4915853a-8ea0-11e8-8983-db9e0f04e772 .png " alt =" Become a Patron " width =" 160 " />] ( https://patreon .com/dmitryivanov )
5+ [ <img src =" https://user-images.githubusercontent.com/1286821/181085373-12eee197-187a-4438-90fe-571ac6d68900 .png " alt =" Buy me a coffee " width =" 200 " />] ( https://buymeacoffee .com/dmitry.ivanov )
66
77[ ![ StyleCI] ( https://github.styleci.io/repos/75414626/shield?branch=9.x&style=flat )] ( https://github.styleci.io/repos/75414626?branch=9.x )
88[ ![ Build Status] ( https://img.shields.io/github/workflow/status/dmitry-ivanov/laravel-testing-tools/tests/9.x )] ( https://github.com/dmitry-ivanov/laravel-testing-tools/actions?query=workflow%3Atests+branch%3A9.x )
@@ -38,7 +38,7 @@ Laravel-specific Testing Helpers and Assertions.
3838 composer require --dev " illuminated/testing-tools:^9.0"
3939 ```
4040
41- 2. Use ` Illuminated\T esting\T estingTools` and disable ` $mockConsoleOutput ` :
41+ 2. Use ` Illuminated\T esting\T estingTools` trait :
4242
4343 ` ` ` php
4444 use Illuminated\T esting\T estingTools;
@@ -47,23 +47,21 @@ Laravel-specific Testing Helpers and Assertions.
4747 {
4848 use TestingTools;
4949
50- public $mockConsoleOutput = false ;
51-
5250 // ...
5351 }
5452 ` ` `
5553
56543. Use any of the provided helpers and assertions in your tests:
5755
5856 ` ` ` php
59- class HelloCommandTest extends TestCase
57+ class ExampleCommandTest extends TestCase
6058 {
6159 /** @test * /
62- public function it_outputs_hello_world ()
60+ public function it_logs_hello_world ()
6361 {
64- $this -> artisan(' hello ' );
62+ $this -> artisan(' example ' );
6563
66- $this -> seeArtisanOutput( ' Hello, World!' );
64+ $this -> seeInLogFile( ' example.log ' , ' Hello World!' );
6765 }
6866 }
6967 ` ` `
@@ -77,26 +75,11 @@ Laravel-specific Testing Helpers and Assertions.
7775 - [emulateProduction](# emulateproduction)
7876 - [emulateEnvironment](# emulateenvironment)
7977 - [isTravis](# istravis)
80- - [ArtisanHelpers](# artisanhelpers)
81- - [runArtisan](# runartisan)
8278
8379# # Available assertions
8480
8581> Feel free to contribute.
8682
87- - [ArtisanAsserts](# artisanasserts)
88- - [willSeeConfirmation](# willseeconfirmation)
89- - [willNotSeeConfirmation](# willnotseeconfirmation)
90- - [willGiveConfirmation](# willgiveconfirmation)
91- - [willNotGiveConfirmation](# willnotgiveconfirmation)
92- - [seeArtisanOutput](# seeartisanoutput)
93- - [dontSeeArtisanOutput](# dontseeartisanoutput)
94- - [seeInArtisanOutput](# seeinartisanoutput)
95- - [dontSeeInArtisanOutput](# dontseeinartisanoutput)
96- - [seeArtisanTableOutput](# seeartisantableoutput)
97- - [dontSeeArtisanTableOutput](# dontseeartisantableoutput)
98- - [seeArtisanTableRowsCount](# seeartisantablerowscount)
99- - [dontSeeArtisanTableRowsCount](# dontseeartisantablerowscount)
10083- [CollectionAsserts](# collectionasserts)
10184 - [assertCollectionsEqual](# assertcollectionsequal)
10285 - [assertCollectionsNotEqual](# assertcollectionsnotequal)
@@ -188,162 +171,8 @@ $this->isTravis();
188171// true
189172` ` `
190173
191- # ## ArtisanHelpers
192-
193- # ### `runArtisan()`
194-
195- Run the given artisan console command:
196-
197- ` ` ` php
198- $command = $this -> runArtisan(MyCommand::class, [' --name' => ' John' ]);
199-
200- // \I lluminate\C onsole\C ommand
201- ` ` `
202-
203- Also, you can pass the command instance as a first argument:
204-
205- ` ` ` php
206- $command = $this -> runArtisan(new MyCommand, [' --name' => ' Jane' ]);
207-
208- // \I lluminate\C onsole\C ommand
209- ` ` `
210-
211174# # Assertions
212175
213- # ## ArtisanAsserts
214-
215- # ### `willSeeConfirmation()`
216-
217- Add expectation that the given confirmation question would be shown:
218-
219- ` ` ` php
220- $this -> willSeeConfirmation(' Are you sure?' , MyCommand::class);
221- ` ` `
222-
223- # ### `willNotSeeConfirmation()`
224-
225- Add expectation that the given confirmation question would not be shown:
226-
227- ` ` ` php
228- $this -> willNotSeeConfirmation(' Are you sure?' , MyCommand::class);
229- ` ` `
230-
231- # ### `willGiveConfirmation()`
232-
233- Add expectation that the given confirmation question would be shown, and accept it:
234-
235- ` ` ` php
236- $this -> willGiveConfirmation(' Are you sure?' , MyCommand::class);
237-
238- $this -> seeArtisanOutput(' Done!' );
239- ` ` `
240-
241- # ### `willNotGiveConfirmation()`
242-
243- Add expectation that the given confirmation question would be shown, and do not accept it:
244-
245- ` ` ` php
246- $this -> willNotGiveConfirmation(' Are you sure?' , MyCommand::class);
247-
248- $this -> dontSeeArtisanOutput(' Done!' );
249- ` ` `
250-
251- # ### `seeArtisanOutput()`
252-
253- Assert that the given artisan output is seen:
254-
255- ` ` ` php
256- $this -> seeArtisanOutput(' Hello, World!' );
257- ` ` `
258-
259- Also, you can specify a path to the file containing output:
260-
261- ` ` ` php
262- $this -> seeArtisanOutput(' correct.output.txt' );
263- ` ` `
264-
265- # ### `dontSeeArtisanOutput()`
266-
267- Assert that the given artisan output is not seen:
268-
269- ` ` ` php
270- $this -> dontSeeArtisanOutput(' Hello, Universe!' );
271- ` ` `
272-
273- Also, you can specify a path to the file containing output:
274-
275- ` ` ` php
276- $this -> dontSeeArtisanOutput(' incorrect.output.txt' );
277- ` ` `
278-
279- # ### `seeInArtisanOutput()`
280-
281- Assert that the given string is seen in the artisan output:
282-
283- ` ` ` php
284- $this -> seeInArtisanOutput(' Hello' );
285- ` ` `
286-
287- Also, you can specify a path to the file containing the string:
288-
289- ` ` ` php
290- $this -> seeInArtisanOutput(' needle.txt' );
291- ` ` `
292-
293- # ### `dontSeeInArtisanOutput()`
294-
295- Assert that the given string is not seen in the artisan output:
296-
297- ` ` ` php
298- $this -> dontSeeInArtisanOutput(' FooBar' );
299- ` ` `
300-
301- Also, you can specify a path to the file containing the string:
302-
303- ` ` ` php
304- $this -> dontSeeInArtisanOutput(' wrong-needle.txt' );
305- ` ` `
306-
307- # ### `seeArtisanTableOutput()`
308-
309- Assert that the given data is seen in the artisan table output:
310-
311- ` ` ` php
312- $this -> seeArtisanTableOutput([
313- [' System' => ' Node-1' , ' Status' => ' Enabled' ],
314- [' System' => ' Node-2' , ' Status' => ' Enabled' ],
315- [' System' => ' Node-3' , ' Status' => ' Enabled' ],
316- ]);
317- ` ` `
318-
319- # ### `dontSeeArtisanTableOutput()`
320-
321- Assert that the given data is not seen in the artisan table output:
322-
323- ` ` ` php
324- $this -> dontSeeArtisanTableOutput([
325- [' System' => ' Node-1' , ' Status' => ' Disabled' ],
326- [' System' => ' Node-2' , ' Status' => ' Disabled' ],
327- [' System' => ' Node-3' , ' Status' => ' Disabled' ],
328- ]);
329- ` ` `
330-
331- # ### `seeArtisanTableRowsCount()`
332-
333- Assert that the artisan table output has the given number of data rows:
334-
335- ` ` ` php
336- $this -> seeArtisanTableRowsCount(3);
337- ` ` `
338-
339- # ### `dontSeeArtisanTableRowsCount()`
340-
341- Assert that the artisan table output doesn' t have the given number of data rows:
342-
343- ```php
344- $this->dontSeeArtisanTableRowsCount(5);
345- ```
346-
347176# ## CollectionAsserts
348177
349178# ### `assertCollectionsEqual()`
0 commit comments