|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Sentry\Laravel\Tests; |
| 4 | + |
| 5 | +use Sentry\State\Hub; |
| 6 | +use Sentry\Laravel\Facade; |
| 7 | +use Sentry\Laravel\ServiceProvider; |
| 8 | + |
| 9 | +class ServiceProviderWithCustomAliasTest extends \Orchestra\Testbench\TestCase |
| 10 | +{ |
| 11 | + protected function getEnvironmentSetUp($app) |
| 12 | + { |
| 13 | + $app[ 'config']-> set( 'custom-sentry.dsn', 'http://publickey:[email protected]/123'); |
| 14 | + $app['config']->set('custom-sentry.error_types', E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED); |
| 15 | + } |
| 16 | + |
| 17 | + protected function getPackageProviders($app) |
| 18 | + { |
| 19 | + return [ |
| 20 | + CustomSentryServiceProvider::class, |
| 21 | + ]; |
| 22 | + } |
| 23 | + |
| 24 | + protected function getPackageAliases($app) |
| 25 | + { |
| 26 | + return [ |
| 27 | + 'CustomSentry' => CustomSentryFacade::class, |
| 28 | + ]; |
| 29 | + } |
| 30 | + |
| 31 | + public function testIsBound() |
| 32 | + { |
| 33 | + $this->assertTrue(app()->bound('custom-sentry')); |
| 34 | + $this->assertInstanceOf(Hub::class, app('custom-sentry')); |
| 35 | + $this->assertSame(app('custom-sentry'), CustomSentryFacade::getFacadeRoot()); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @depends testIsBound |
| 40 | + */ |
| 41 | + public function testEnvironment() |
| 42 | + { |
| 43 | + $this->assertEquals('testing', app('custom-sentry')->getClient()->getOptions()->getEnvironment()); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @depends testIsBound |
| 48 | + */ |
| 49 | + public function testDsnWasSetFromConfig() |
| 50 | + { |
| 51 | + /** @var \Sentry\Options $options */ |
| 52 | + $options = app('custom-sentry')->getClient()->getOptions(); |
| 53 | + |
| 54 | + $this->assertEquals('http://sentry.dev', $options->getDsn()); |
| 55 | + $this->assertEquals(123, $options->getProjectId()); |
| 56 | + $this->assertEquals('publickey', $options->getPublicKey()); |
| 57 | + $this->assertEquals('secretkey', $options->getSecretKey()); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * @depends testIsBound |
| 62 | + */ |
| 63 | + public function testErrorTypesWasSetFromConfig() |
| 64 | + { |
| 65 | + $this->assertEquals( |
| 66 | + E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED, |
| 67 | + app('custom-sentry')->getClient()->getOptions()->getErrorTypes() |
| 68 | + ); |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +class CustomSentryServiceProvider extends ServiceProvider |
| 73 | +{ |
| 74 | + public static $abstract = 'custom-sentry'; |
| 75 | +} |
| 76 | + |
| 77 | +class CustomSentryFacade extends Facade |
| 78 | +{ |
| 79 | + protected static function getFacadeAccessor() |
| 80 | + { |
| 81 | + return 'custom-sentry'; |
| 82 | + } |
| 83 | +} |
0 commit comments