-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
225 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Tests | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
fail-fast: false | ||
|
||
name: PHP ${{ matrix.php }} tests | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: none | ||
|
||
- name: Add NewRelic APT source | ||
run: echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list | ||
- name: Add NewRelic APT key | ||
run: wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add - | ||
- name: Update APT | ||
run: sudo apt-get update | ||
- name: Install NewRelic PHP extension | ||
run: sudo apt-get -y install newrelic-php5 | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- run: composer install --no-progress --prefer-dist | ||
- run: composer tests | ||
- if: failure() | ||
run: for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done | ||
shell: bash | ||
|
||
|
||
lowest_dependencies: | ||
name: Lowest Dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: shivammathur/setup-php@v1 | ||
with: | ||
php-version: 7.1 | ||
coverage: none | ||
|
||
- name: Add NewRelic APT source | ||
run: echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list | ||
- name: Add NewRelic APT key | ||
run: wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add - | ||
- name: Update APT | ||
run: sudo apt-get update | ||
- name: Install NewRelic PHP extension | ||
run: sudo apt-get -y install newrelic-php5 | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable | ||
- run: composer tests | ||
- if: failure() | ||
run: for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace ContributteTests\NewRelic\Cases; | ||
|
||
use Contributte\NewRelic\Callbacks\OnErrorCallback; | ||
use Contributte\NewRelic\Callbacks\OnRequestCallback; | ||
use Contributte\NewRelic\DI\NewRelicExtension; | ||
use ContributteTests\NewRelic\Mocks\ApplicationExtension; | ||
use Nette\DI\Compiler; | ||
use Nette\DI\Container; | ||
use Nette\DI\ContainerLoader; | ||
use Tester\Assert; | ||
use Tester\TestCase; | ||
|
||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
/** | ||
* @TestCase | ||
*/ | ||
final class NewRelicExtensionTest extends TestCase | ||
{ | ||
|
||
public function testExtension(): void | ||
{ | ||
$loader = new ContainerLoader(TEMP_DIR, true); | ||
$class = $loader->load(function (Compiler $compiler): void { | ||
$compiler->addConfig([ | ||
'newrelic' => [ | ||
'enabled' => true, | ||
'appName' => 'YourApplicationName', | ||
'license' => 'yourLicenseCode', | ||
'actionKey' => 'action', | ||
'logLevel' => [ | ||
'critical', | ||
'exception', | ||
'error', | ||
], | ||
'rum' => [ | ||
'enabled' => 'true', | ||
], | ||
'transactionTracer' => [ | ||
'enabled' => true, | ||
'detail' => 1, | ||
'recordSql' => 'obfuscated', | ||
'slowSql' => true, | ||
'threshold' => 'apdex_f', | ||
'stackTraceThreshold' => 500, | ||
'explainThreshold' => 500, | ||
], | ||
'errorCollector' => [ | ||
'enabled' => true, | ||
'recordDatabaseErrors' => true, | ||
], | ||
'parameters' => [ | ||
'capture' => false, | ||
'ignored' => [], | ||
], | ||
'custom' => [ | ||
'parameters' => [ | ||
'paramName' => 'paramValue', | ||
], | ||
'tracers' => [], | ||
], | ||
], | ||
]); | ||
$compiler->addExtension('application', new ApplicationExtension()); | ||
$compiler->addExtension('newrelic', new NewRelicExtension()); | ||
}, [getmypid(), 1]); | ||
|
||
/** @var Container $container */ | ||
$container = new $class(); | ||
|
||
Assert::count(1, $container->findByType(OnRequestCallback::class)); | ||
Assert::count(1, $container->findByType(OnErrorCallback::class)); | ||
} | ||
|
||
} | ||
|
||
(new NewRelicExtensionTest())->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace ContributteTests\NewRelic\Mocks; | ||
|
||
final class Application | ||
{ | ||
public $onRequest = []; | ||
public $onError = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ContributteTests\NewRelic\Mocks; | ||
|
||
use Nette; | ||
|
||
|
||
/** | ||
* Application extension for Nette DI. | ||
*/ | ||
final class ApplicationExtension extends Nette\DI\CompilerExtension | ||
{ | ||
|
||
public function loadConfiguration() | ||
{ | ||
$config = $this->config; | ||
$builder = $this->getContainerBuilder(); | ||
|
||
$builder->addDefinition('application') | ||
->setFactory(Application::class); | ||
|
||
$this->compiler->addExportedType(Application::class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Ninjify\Nunjuck\Environment; | ||
|
||
if (@!include __DIR__ . '/../vendor/autoload.php') { | ||
echo 'Install Nette Tester using `composer update --dev`'; | ||
exit(1); | ||
} | ||
|
||
// Configure environment | ||
Environment::setup(__DIR__); |