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 27
27
"ext-curl" : " *"
28
28
},
29
29
"require-dev" : {
30
- "orchestra/testbench" : " ^7.0|^8.0 " ,
30
+ "orchestra/testbench" : " ^7.22 " ,
31
31
"pestphp/pest" : " ^1.21" ,
32
32
"pestphp/pest-plugin-laravel" : " ^1.1" ,
33
33
"friendsofphp/php-cs-fixer" : " ^3.9" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class MsGraphServiceProvider extends ServiceProvider
16
16
*/
17
17
public function boot (Router $ router )
18
18
{
19
+ $ this ->mergeConfigFrom (__DIR__ .'/../config/msgraph.php ' , 'msgraph ' );
19
20
$ this ->loadMigrationsFrom (__DIR__ .'/../database/migrations ' );
20
21
$ this ->registerMiddleware ($ router );
21
22
@@ -63,8 +64,6 @@ public function configurePublishing()
63
64
*/
64
65
public function register ()
65
66
{
66
- $ this ->mergeConfigFrom (__DIR__ .'/../config/msgraph.php ' , 'msgraph ' );
67
-
68
67
// Register the service the package provides.
69
68
$ this ->app ->singleton ('msgraph ' , function ($ app ) {
70
69
return new MsGraph ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
use Dcblogdev \MsGraph \Models \MsGraphToken ;
4
+ use Dcblogdev \MsGraph \Facades \MsGraphAdmin as MsGraphAdminFacade ;
4
5
use Dcblogdev \MsGraph \MsGraphAdmin ;
5
6
6
7
beforeEach (function () {
21
22
$ this ->artisan ('msgraphadmin:keep-alive ' )
22
23
->expectsOutput ('connected ' );
23
24
});
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 2
2
3
3
namespace Dcblogdev \MsGraph \Tests ;
4
4
5
- use create_ms_graph_tokens_table ;
5
+ use AllowDynamicProperties ;
6
6
use Dcblogdev \MsGraph \MsGraphServiceProvider ;
7
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
7
8
use Orchestra \Testbench \TestCase as Orchestra ;
8
9
9
10
class TestCase extends Orchestra
10
11
{
12
+ use RefreshDatabase;
13
+
11
14
protected function getPackageProviders ($ app )
12
15
{
13
16
return [
14
17
MsGraphServiceProvider::class,
15
18
];
16
19
}
17
20
18
- /**
19
- * Define environment setup.
20
- *
21
- * @param \Illuminate\Foundation\Application $app
22
- * @return void
23
- */
24
21
protected function getEnvironmentSetUp ($ app )
25
22
{
26
23
// 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 ' , [
29
26
'driver ' => 'sqlite ' ,
30
27
'database ' => ':memory: ' ,
31
28
'prefix ' => '' ,
32
29
]);
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 ();
38
30
}
39
31
}
You can’t perform that action at this time.
0 commit comments