@@ -40,25 +40,53 @@ public function test_standard_export_works()
40
40
41
41
public function test_bearer_export_works ()
42
42
{
43
- $ this ->artisan ('export:postman --bearer=1234567890 ' )
44
- ->assertExitCode (0 );
43
+ $ this ->artisan ('export:postman --bearer=1234567890 ' )->assertExitCode (0 );
45
44
46
- $ this ->assertTrue (true );
45
+ $ collection = json_decode (Storage::get ('postman/ ' .config ('api-postman.filename ' )), true );
46
+
47
+ $ routes = $ this ->app ['router ' ]->getRoutes ();
48
+
49
+ $ collectionVariables = $ collection ['variable ' ];
50
+
51
+ foreach ($ collectionVariables as $ variable ) {
52
+ if ($ variable ['key ' ] != 'token ' ) {
53
+ continue ;
54
+ }
47
55
48
- // ensure output contains json x
56
+ $ this ->assertEquals ($ variable ['value ' ], '1234567890 ' );
57
+ }
58
+
59
+ $ this ->assertCount (2 , $ collectionVariables );
60
+
61
+ $ collectionItems = $ collection ['item ' ];
49
62
50
- // ensure output has headers and variable json
63
+ $ this ->assertCount (count ($ routes ), $ collectionItems );
64
+
65
+ foreach ($ routes as $ route ) {
66
+ $ collectionRoute = Arr::first ($ collectionItems , function ($ item ) use ($ route ) {
67
+ return $ item ['name ' ] == $ route ->uri ();
68
+ });
69
+
70
+ $ this ->assertNotNull ($ collectionRoute );
71
+ $ this ->assertTrue (in_array ($ collectionRoute ['request ' ]['method ' ], $ route ->methods ()));
72
+ }
51
73
}
52
74
53
75
public function test_structured_export_works ()
54
76
{
55
- // set structured to true in config
77
+ config ()-> set ( ' api-postman. structured' , true );
56
78
57
79
$ this ->artisan ('export:postman ' )
58
80
->assertExitCode (0 );
59
81
60
82
$ this ->assertTrue (true );
61
83
62
- // ensure output contains json x
84
+ $ collection = json_decode (Storage::get ('postman/ ' .config ('api-postman.filename ' )), true );
85
+
86
+ $ routes = $ this ->app ['router ' ]->getRoutes ();
87
+
88
+ $ collectionItems = $ collection ['item ' ];
89
+
90
+ $ this ->assertCount (count ($ routes ), $ collectionItems [0 ]['item ' ]);
63
91
}
64
92
}
0 commit comments