Skip to content

Commit

Permalink
Merge pull request #15 from michaelarnauts/environment-fix
Browse files Browse the repository at this point in the history
Move environment out of tags to the root
  • Loading branch information
albertborsos authored Mar 30, 2017
2 parents 6ebfd3a + 87964e4 commit a0676f0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ private function setEnvironmentOptions()
return;
}

if (is_object($this->client) && property_exists($this->client, 'tags')) {
$this->client->tags = ArrayHelper::merge($this->client->tags, ['environment' => $this->environment]);
if (is_object($this->client) && property_exists($this->client, 'environment')) {
$this->client->environment = $this->environment;
}
$this->jsOptions['tags']['environment'] = $this->environment;
$this->jsOptions['environment'] = $this->environment;
}

private function setRavenClient()
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ public function testSetEnvironment($environment, $expected, $configType, $client
$this->assertEquals($expected, $component->environment);
$this->assertInstanceOf($clientClass, $component->client);
if (!empty($environment)) {
$this->assertArrayHasKey('tags', $component->jsOptions);
$this->assertArrayHasKey('environment', $component->client->tags);
$this->assertEquals($expected, $component->client->tags['environment']);
$this->assertEquals($expected, $component->jsOptions['tags']['environment']);
$this->assertEquals($expected, $component->client->tags['environment']);
$this->assertArrayHasKey('environment', $component->jsOptions);
$this->assertObjectHasAttribute('environment', $component->client);
$this->assertEquals($expected, $component->client->environment);
$this->assertEquals($expected, $component->jsOptions['environment']);
}
}

Expand Down Expand Up @@ -159,8 +158,8 @@ public function testClientConfig($configType, $clientClass)
$this->assertEquals(self::PRIVATE_DSN, $component->client->dsn);
$this->assertArrayHasKey('test', $component->client->tags);
$this->assertEquals('value', $component->client->tags['test']);
$this->assertArrayHasKey('environment', $component->client->tags);
$this->assertEquals(self::ENV_DEVELOPMENT, $component->client->tags['environment']);
$this->assertObjectHasAttribute('environment', $component->client);
$this->assertEquals(self::ENV_DEVELOPMENT, $component->client->environment);
}

public function invalidConfigs()
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/DummyRavenClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
class DummyRavenClient
{
public $tags = [];
public $environment;
public $dsn;

public function __construct($dsn, $options)
{
if (isset($options['tags'])) {
$this->tags = $options['tags'];
}
if (isset($options['environment'])) {
$this->environment = $options['environment'];
}
$this->dsn = $dsn;
}
}

0 comments on commit a0676f0

Please sign in to comment.