@@ -18,12 +18,11 @@ protected function setUp(): void
1818 parent ::setUp ();
1919
2020 if (!$ this ->migrated ) {
21- $ this ->loadMigrationsFrom (__DIR__ . '/../src/migrations ' );
21+ $ this ->loadMigrationsFrom (__DIR__ . '/../src/migrations ' );
2222 if ($ this ->artisan ('migrate ' , [
2323 '--database ' => 'mysql ' ])) {
2424 $ this ->migrated = true ;
2525 }
26-
2726 }
2827 }
2928
@@ -106,6 +105,8 @@ protected function getEnvironmentSetUp($app)
106105 'name ' => 'limited ' ,
107106 ]
108107 ]);
108+
109+ $ app ['config ' ]->set ('logtodb ' , include __DIR__ .'/../src/config/logtodb.php ' );
109110 }
110111
111112 /**
@@ -126,24 +127,6 @@ protected function getPackageProviders($app)
126127 ];
127128 }
128129
129- /**
130- * Test the vendor:publish command for the migration file.
131- *
132- * @group publish
133- */
134- public function testVendorPublish ()
135- {
136- $ this ->artisan ('vendor:publish ' , [
137- '--tag ' => 'migrations ' ,
138- '--provider ' => 'danielme85\LaravelLogToDB\ServiceProvider '
139- ])->assertExitCode (0 );
140-
141- $ this ->artisan ('vendor:publish ' , [
142- '--tag ' => 'config ' ,
143- '--provider ' => 'danielme85\LaravelLogToDB\ServiceProvider '
144- ])->assertExitCode (0 );
145- }
146-
147130 /**
148131 * Basic test to see if class can be instanced.
149132 *
@@ -159,7 +142,6 @@ public function testClassInit()
159142 LogToDB::model ('mongodb ' )->truncate ();
160143 }
161144
162-
163145 /**
164146 * Run basic log levels
165147 *
@@ -356,16 +338,6 @@ public function testSaveNewLogEventJob()
356338 $ this ->assertNotEmpty ($ logToDb ->model ()->where ('message ' , '= ' , 'job-test ' )->get ());
357339 }
358340
359- /**
360- * Test exception on save new log job.
361- * @group job
362- */
363- public function testExceptionOnSaveNewLogEvent ()
364- {
365- $ this ->expectException (DBLogException::class);
366- $ job = new SaveNewLogEvent (false , []);
367- $ job ->handle ();
368- }
369341
370342 /**
371343 * Test model interaction
@@ -374,6 +346,8 @@ public function testExceptionOnSaveNewLogEvent()
374346 */
375347 public function testModelInteraction ()
376348 {
349+ LogToDB::model ()->truncate ();
350+ LogToDB::model ('mongodb ' )->truncate ();
377351
378352 for ($ i =1 ; $ i <=10 ; $ i ++) {
379353 Log::debug ("This is debug log message... " );
@@ -447,6 +421,7 @@ public function testModelInteraction()
447421 $ logs = $ modelMongo ->where ('level_name ' , '= ' , 'DEBUG ' )->get ()->toArray ();
448422 $ this ->assertNotEmpty ($ logs );
449423 $ this ->assertEquals ('DEBUG ' , $ logs [0 ]['level_name ' ]);
424+ $ this ->assertCount (10 , $ logs );
450425
451426 //Same tests for mongoDB
452427 $ modelMongo = LogToDB::model ('mongodb ' , 'mongodb ' , 'log ' );
@@ -457,6 +432,7 @@ public function testModelInteraction()
457432 $ logs = $ modelMongo ->where ('level_name ' , '= ' , 'DEBUG ' )->get ()->toArray ();
458433 $ this ->assertNotEmpty ($ logs );
459434 $ this ->assertEquals ('DEBUG ' , $ logs [0 ]['level_name ' ]);
435+ $ this ->assertCount (10 , $ logs );
460436
461437 //Same tests for mongoDB
462438 $ modelMongo = LogToDB::model (null , 'mongodb ' );
@@ -467,10 +443,9 @@ public function testModelInteraction()
467443 $ logs = $ modelMongo ->where ('level_name ' , '= ' , 'DEBUG ' )->get ()->toArray ();
468444 $ this ->assertNotEmpty ($ logs );
469445 $ this ->assertEquals ('DEBUG ' , $ logs [0 ]['level_name ' ]);
470-
446+ $ this -> assertCount ( 10 , $ logs );
471447 }
472448
473-
474449 /**
475450 * $group model
476451 */
0 commit comments