|
4 | 4 |
|
5 | 5 | namespace Verbanent\Uuid\Test\Providers; |
6 | 6 |
|
| 7 | +use Illuminate\Config\Repository; |
7 | 8 | use Illuminate\Contracts\Foundation\Application; |
8 | 9 | use Illuminate\Database\MySqlConnection; |
| 10 | +use Illuminate\Support\ServiceProvider; |
9 | 11 | use Mockery; |
10 | 12 | use PHPUnit\Framework\TestCase; |
11 | 13 | use Verbanent\Uuid\Providers\BinaryUuidServiceProvider; |
@@ -35,4 +37,41 @@ public function testBoot() |
35 | 37 | $this->assertInstanceOf(BinaryUuidServiceProvider::class, $this->binaryUuidServiceProvider); |
36 | 38 | $this->assertNull($this->binaryUuidServiceProvider->boot()); |
37 | 39 | } |
| 40 | + |
| 41 | + public function testRegisterMergesConfig() |
| 42 | + { |
| 43 | + $config = new Repository([]); |
| 44 | + $app = Mockery::mock(Application::class); |
| 45 | + $app->shouldReceive('make')->with('config')->andReturn($config); |
| 46 | + |
| 47 | + $provider = new BinaryUuidServiceProvider($app); |
| 48 | + $provider->register(); |
| 49 | + |
| 50 | + $this->assertSame('id', $config->get('binary-uuid.default_column')); |
| 51 | + } |
| 52 | + |
| 53 | + public function testBootPublishesConfigWhenRunningInConsole() |
| 54 | + { |
| 55 | + $app = Mockery::mock(Application::class); |
| 56 | + $app->shouldReceive('runningInConsole')->andReturn(true); |
| 57 | + $app->shouldReceive('configPath')->with('binary-uuid.php')->andReturn('/tmp/binary-uuid.php'); |
| 58 | + |
| 59 | + $provider = new BinaryUuidServiceProvider($app); |
| 60 | + $provider->boot(); |
| 61 | + |
| 62 | + $paths = ServiceProvider::pathsToPublish( |
| 63 | + BinaryUuidServiceProvider::class, |
| 64 | + 'binary-uuid-config' |
| 65 | + ); |
| 66 | + |
| 67 | + $this->assertNotEmpty($paths); |
| 68 | + $this->assertTrue(in_array('/tmp/binary-uuid.php', array_values($paths), true)); |
| 69 | + } |
| 70 | + |
| 71 | + protected function tearDown(): void |
| 72 | + { |
| 73 | + Mockery::close(); |
| 74 | + ServiceProvider::$publishes = []; |
| 75 | + ServiceProvider::$publishGroups = []; |
| 76 | + } |
38 | 77 | } |
0 commit comments