Skip to content

Commit

Permalink
adding in missing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Steuernol committed Jun 29, 2016
1 parent 7e54a67 commit e33c692
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getConfigArray()
protected function updateConfig($c)
{
$this->configArray = $c;

$this->setAccessToken($c);
$this->setDataBuilder($c);
$this->setTransformer($c);
Expand Down Expand Up @@ -119,6 +119,10 @@ private function setSender($c)
$expected = "Rollbar\Senders\SenderInterface";
$default = "Rollbar\Senders\CurlSender";

if (array_key_exists('base_api_url', $c)) {
$c['senderOptions']['endpoint'] = $c['base_api_url'];
}

if (array_key_exists('handler', $c) && $c['handler'] == 'agent') {
$default = "Rollbar\Senders\AgentSender";
if (array_key_exists('agent_log_location', $c)) {
Expand Down Expand Up @@ -226,6 +230,9 @@ public function checkIgnored($payload, $accessToken)
}
if (!is_null($this->filter)) {
return $this->filter->shouldSend($payload, $accessToken);
}
if (isset($this->checkIgnoreFunction)) {

}
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion src/DataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ protected function setServerRoot($c)
protected function setServerBranch($c)
{
$fromConfig = $this->tryGet($c, 'serverBranch');
if (!isset($fromConfig))
$fromConfig = $this->tryGet($c, 'branch');
$this->serverBranch = self::$defaults->gitBranch($fromConfig);
}

Expand Down Expand Up @@ -224,7 +226,7 @@ protected function setBaseException($c)

/**
* @param Level $level
* @param \Exception | \Throwable $toLog
* @param \Exception | \Throwable | string $toLog
* @param $context
* @return Data
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Payload/Data.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Rollbar\Payload;

use Rollbar\Defaults;
use Rollbar\Utilities;

class Data implements \JsonSerializable
Expand Down Expand Up @@ -159,6 +160,9 @@ public function setPerson(Person $person = null)
return $this;
}

/**
* @return Server
*/
public function getServer()
{
return $this->server;
Expand Down
20 changes: 20 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use \Mockery as m;
use Rollbar\FakeDataBuilder;
use Rollbar\Payload\Body;
use Rollbar\Payload\Data;
use Rollbar\Payload\Level;
use Rollbar\Payload\Message;
use Rollbar\Payload\Payload;
use Psr\Log\LogLevel;

Expand Down Expand Up @@ -187,4 +190,21 @@ public function testSender()
));
$c->send($p, $this->token);
}

public function testCheckIgnore()
{
$called = false;
$c = new Config(array(
"access_token" => $this->token,
"environment" => $this->env,
"checkIgnore" => function() use (&$called) {
$called = true;
}
));
$data = new Data($this->env, new Body(new Message("test")));
$data->setLevel(Level::fromName('error'));
$c->checkIgnored(new Payload($data, $this->token), $this->token);

$this->assertTrue($called);
}
}
18 changes: 18 additions & 0 deletions tests/DataBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

class DataBuilderTest extends \PHPUnit_Framework_TestCase
{
public function __construct()
{
parent::__construct();
$_SESSION = array();
}

/**
* @var DataBuilder
*/
Expand All @@ -24,4 +30,16 @@ public function testMakeData()
$output = $this->dataBuilder->makeData(Level::fromName('error'), "testing", array());
$this->assertEquals('tests', $output->getEnvironment());
}

public function testBranchKey()
{
$dataBuilder = new DataBuilder(array(
'accessToken' => 'abcd1234efef5678abcd1234567890be',
'environment' => 'tests',
'branch' => 'test-branch'
));

$output = $dataBuilder->makeData(Level::fromName('error'), "testing", array());
$this->assertEquals('test-branch', $output->getServer()->getBranch());
}
}
1 change: 0 additions & 1 deletion tests/RollbarLoggerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php namespace Rollbar;

use Rollbar\RollbarLogger;
use Psr\Log\LogLevel;

class RollbarLoggerTest extends \PHPUnit_Framework_TestCase
Expand Down

0 comments on commit e33c692

Please sign in to comment.