Skip to content

Commit

Permalink
Mock Composer\InstalledVersions getRootPackage call for improved cove…
Browse files Browse the repository at this point in the history
…rage.
  • Loading branch information
ChrisLightfootWild committed Nov 20, 2023
1 parent bf21fd4 commit 34e6c2c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/Unit/SDK/SdkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace OpenTelemetry\Tests\Unit\SDK;

use AssertWell\PHPUnitGlobalState\EnvironmentVariables;
use Composer\InstalledVersions;
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
use OpenTelemetry\SDK\Common\Configuration\Variables;
use OpenTelemetry\SDK\Logs\LoggerProviderInterface;
Expand Down Expand Up @@ -83,6 +84,14 @@ public function test_developer_mode_auto_detected(): void
$this->assertTrue(Sdk::isDeveloperModeEnabled());
}

public function test_developer_mode_check_handles_exceptions(): void
{
$mock = \Mockery::mock('alias:' . InstalledVersions::class);
$mock->expects('getRootPackage')->andThrow(\Exception::class);

$this->assertFalse(Sdk::isDeveloperModeEnabled());
}

public function test_builder(): void
{
$this->assertInstanceOf(SdkBuilder::class, Sdk::builder());
Expand Down

0 comments on commit 34e6c2c

Please sign in to comment.