Skip to content

Commit c75f54f

Browse files
committed
wip
1 parent f42c5dc commit c75f54f

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
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",

src/MsGraphServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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;

tests/MsGraphAdminTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Dcblogdev\MsGraph\Models\MsGraphToken;
4+
use Dcblogdev\MsGraph\Facades\MsGraphAdmin as MsGraphAdminFacade;
45
use Dcblogdev\MsGraph\MsGraphAdmin;
56

67
beforeEach(function () {
@@ -21,3 +22,22 @@
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+
});

tests/TestCase.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,30 @@
22

33
namespace Dcblogdev\MsGraph\Tests;
44

5-
use create_ms_graph_tokens_table;
5+
use AllowDynamicProperties;
66
use Dcblogdev\MsGraph\MsGraphServiceProvider;
7+
use Illuminate\Foundation\Testing\RefreshDatabase;
78
use Orchestra\Testbench\TestCase as Orchestra;
89

910
class 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
}

0 commit comments

Comments
 (0)