File tree Expand file tree Collapse file tree 4 files changed +28
-17
lines changed
Expand file tree Collapse file tree 4 files changed +28
-17
lines changed Original file line number Diff line number Diff line change 2727 "ext-curl" : " *"
2828 },
2929 "require-dev" : {
30- "orchestra/testbench" : " ^7.0|^8.0 " ,
30+ "orchestra/testbench" : " ^7.22 " ,
3131 "pestphp/pest" : " ^1.21" ,
3232 "pestphp/pest-plugin-laravel" : " ^1.1" ,
3333 "friendsofphp/php-cs-fixer" : " ^3.9" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class MsGraphServiceProvider extends ServiceProvider
1616 */
1717 public function boot (Router $ router )
1818 {
19+ $ this ->mergeConfigFrom (__DIR__ .'/../config/msgraph.php ' , 'msgraph ' );
1920 $ this ->loadMigrationsFrom (__DIR__ .'/../database/migrations ' );
2021 $ this ->registerMiddleware ($ router );
2122
@@ -63,8 +64,6 @@ public function configurePublishing()
6364 */
6465 public function register ()
6566 {
66- $ this ->mergeConfigFrom (__DIR__ .'/../config/msgraph.php ' , 'msgraph ' );
67-
6867 // Register the service the package provides.
6968 $ this ->app ->singleton ('msgraph ' , function ($ app ) {
7069 return new MsGraph ;
Original file line number Diff line number Diff line change 11<?php
22
33use Dcblogdev \MsGraph \Models \MsGraphToken ;
4+ use Dcblogdev \MsGraph \Facades \MsGraphAdmin as MsGraphAdminFacade ;
45use Dcblogdev \MsGraph \MsGraphAdmin ;
56
67beforeEach (function () {
2122 $ this ->artisan ('msgraphadmin:keep-alive ' )
2223 ->expectsOutput ('connected ' );
2324});
25+
26+ test ('is connected returns false when no data in db ' , function () {
27+ $ connect = MsGraphAdminFacade::isConnected ();
28+
29+ expect ($ connect )->toBeFalse ();
30+ });
31+
32+ test ('is connected returns true when data exists in db ' , function () {
33+ $ userId = 1 ;
34+ MsGraphToken::create ([
35+ 'user_id ' => $ userId ,
36+ 'access_token ' => 'ghgh4h22 ' ,
37+ 'expires ' => strtotime ('+1 day ' ),
38+ ]);
39+
40+ $ connect = MsGraphAdminFacade::isConnected ($ userId );
41+
42+ expect ($ connect )->toBeTrue ();
43+ });
Original file line number Diff line number Diff line change 22
33namespace Dcblogdev \MsGraph \Tests ;
44
5- use create_ms_graph_tokens_table ;
5+ use AllowDynamicProperties ;
66use Dcblogdev \MsGraph \MsGraphServiceProvider ;
7+ use Illuminate \Foundation \Testing \RefreshDatabase ;
78use Orchestra \Testbench \TestCase as Orchestra ;
89
910class TestCase extends Orchestra
1011{
12+ use RefreshDatabase;
13+
1114 protected function getPackageProviders ($ app )
1215 {
1316 return [
1417 MsGraphServiceProvider::class,
1518 ];
1619 }
1720
18- /**
19- * Define environment setup.
20- *
21- * @param \Illuminate\Foundation\Application $app
22- * @return void
23- */
2421 protected function getEnvironmentSetUp ($ app )
2522 {
2623 // Setup default database to use sqlite :memory:
27- $ app ['config ' ]->set ('database.default ' , 'mysql ' );
28- $ app ['config ' ]->set ('database.connections.mysql ' , [
24+ $ app ['config ' ]->set ('database.default ' , 'testbench ' );
25+ $ app ['config ' ]->set ('database.connections.testbench ' , [
2926 'driver ' => 'sqlite ' ,
3027 'database ' => ':memory: ' ,
3128 'prefix ' => '' ,
3229 ]);
33-
34- require_once 'src/database/migrations/create_ms_graph_tokens_table.php ' ;
35-
36- // run the up() method of that migration class
37- (new create_ms_graph_tokens_table )->up ();
3830 }
3931}
You can’t perform that action at this time.
0 commit comments