-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit eadf02c
Showing
15 changed files
with
242 additions
and
0 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,4 @@ | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
tests export-ignore |
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,7 @@ | ||
vendor | ||
composer.lock | ||
.idea | ||
tests/tmp/* | ||
|
||
!.gitignore | ||
!.gitkeep |
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,37 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
php: | ||
- 7.1 | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 7.1 | ||
env: PHPSTAN=1 | ||
- php: 7.1 | ||
env: CODING_STANDARD=1 | ||
- php: 7.1 | ||
env: COVERAGE="--coverage coverage.xml --coverage-src src" TESTER_RUNTIME="phpdbg" | ||
|
||
install: | ||
- travis_retry composer update --no-interaction --no-suggest --no-progress --prefer-dist | ||
- travis_retry composer create-project --no-interaction jakub-onderka/php-parallel-lint /tmp/php-parallel-lint | ||
- if [ "$COVERAGE" != "" ]; then travis_retry wget -O /tmp/coveralls.phar https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi | ||
|
||
script: | ||
- vendor/bin/tester $COVERAGE -s -p ${TESTER_RUNTIME:-php} tests | ||
- php /tmp/php-parallel-lint/parallel-lint.php -e php,phpt --exclude vendor . | ||
- if [ "$PHPSTAN" = "1" ]; then php vendor/bin/phpstan.phar analyse --ansi --no-progress -l7 -c phpstan.neon src tests; fi | ||
- if [ "$CODING_STANDARD" = "1" ]; then php vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 -sp src tests; fi | ||
|
||
after_script: | ||
- if [ "$COVERAGE" != "" ]; then php /tmp/coveralls.phar --verbose --config tests/.coveralls.yml || true; fi | ||
|
||
after_failure: | ||
- 'for i in $(find ./tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done' |
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,38 @@ | ||
{ | ||
"name": "grand-media/sentry", | ||
"description": "GrandMedia Sentry", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Grand Media s.r.o.", | ||
"email": "[email protected]", | ||
"homepage": "https://www.grandmedia.cz" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/GrandMedia/Sentry/issues" | ||
}, | ||
"require": { | ||
"php": ">=7.1", | ||
"nette/di": "^3.0", | ||
"sentry/sdk": "^2.1" | ||
}, | ||
"require-dev": { | ||
"grand-media/coding-standard": "^2.0", | ||
"nette/bootstrap": "^3.0", | ||
"nette/reflection": "^2.4", | ||
"nette/tester": "^2.0", | ||
"phpstan/phpstan": "^0.12", | ||
"mockery/mockery": "^1.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"GrandMedia\\Sentry\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"GrandMediaTests\\": "tests/" | ||
} | ||
} | ||
} |
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,8 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2017 Grand Media s.r.o. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,4 @@ | ||
parameters: | ||
excludes_analyse: | ||
- %currentWorkingDirectory%/tests/tmp/* | ||
- %currentWorkingDirectory%/tests/Sentry/Mocks/EntityManagerMock |
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,17 @@ | ||
GrandMedia/Sentry | ||
====== | ||
|
||
[![Build Status](https://travis-ci.org/GrandMedia/Sentry.svg?branch=master)](https://travis-ci.org/GrandMedia/Sentry) | ||
[![Downloads this Month](https://img.shields.io/packagist/dm/grand-media/sentry.svg)](https://packagist.org/packages/grand-media/sentry) | ||
[![Latest stable](https://img.shields.io/packagist/v/grand-media/sentry.svg)](https://packagist.org/packages/grand-media/sentry) | ||
[![Coverage Status](https://coveralls.io/repos/github/GrandMedia/Sentry/badge.svg?branch=master)](https://coveralls.io/github/GrandMedia/Sentry?branch=master) | ||
![PHPStan](https://img.shields.io/badge/style-level%207-brightgreen.svg?style=flat-square&label=phpstan) | ||
|
||
Installation | ||
------------ | ||
|
||
The best way to install GrandMedia/Sentry is using [Composer](http://getcomposer.org/): | ||
|
||
```sh | ||
$ composer require grand-media/sentry | ||
``` |
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,4 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="GrandMedia/Sentry"> | ||
<rule ref="vendor/grand-media/coding-standard/GrandMediaCodingStandard/ruleset.xml"/> | ||
</ruleset> |
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,33 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace GrandMedia\Sentry\DI; | ||
|
||
use GrandMedia\Sentry\HubFactory; | ||
use Nette\Schema\Expect; | ||
use Nette\Schema\Schema; | ||
use Sentry\State\HubInterface; | ||
|
||
final class SentryExtension extends \Nette\DI\CompilerExtension | ||
{ | ||
|
||
public function getConfigSchema(): Schema | ||
{ | ||
return Expect::structure( | ||
[ | ||
'dsn' => Expect::string(), | ||
] | ||
); | ||
} | ||
|
||
public function loadConfiguration(): void | ||
{ | ||
/** @var \stdClass $config */ | ||
$config = $this->getConfig(); | ||
$containerBuilder = $this->getContainerBuilder(); | ||
|
||
$containerBuilder->addDefinition($this->prefix('hub')) | ||
->setType(HubInterface::class) | ||
->setFactory([HubFactory::class, 'create'], ['dsn' => $config->dsn]); | ||
} | ||
|
||
} |
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,22 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace GrandMedia\Sentry; | ||
|
||
use Sentry\ClientBuilder; | ||
use Sentry\SentrySdk; | ||
use Sentry\State\HubInterface; | ||
|
||
final class HubFactory | ||
{ | ||
|
||
public static function create(string $dsn): HubInterface | ||
{ | ||
$hub = SentrySdk::init(); | ||
|
||
$client = ClientBuilder::create(['dsn' => $dsn])->getClient(); | ||
$hub->bindClient($client); | ||
|
||
return $hub; | ||
} | ||
|
||
} |
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,3 @@ | ||
service_name: travis-ci | ||
coverage_clover: coverage.xml | ||
json_path: coverage.json |
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,41 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace GrandMediaTests\Sentry\DI; | ||
|
||
use Nette\Configurator; | ||
use Nette\DI\Container; | ||
use Sentry\State\HubInterface; | ||
use Tester\Assert; | ||
|
||
require_once __DIR__ . '/../../bootstrap.php'; | ||
|
||
/** | ||
* @testCase | ||
*/ | ||
final class SentryExtensionTest extends \Tester\TestCase | ||
{ | ||
|
||
public function testFunctionality(): void | ||
{ | ||
$container = $this->createContainer(null); | ||
|
||
$hub = $container->getByType(HubInterface::class); | ||
Assert::true($hub instanceof HubInterface); | ||
} | ||
|
||
private function createContainer(?string $configFile): Container | ||
{ | ||
$config = new Configurator(); | ||
|
||
$config->setTempDirectory(\TEMP_DIR); | ||
$config->addConfig(__DIR__ . '/config/reset.neon'); | ||
if ($configFile !== null) { | ||
$config->addConfig(__DIR__ . \sprintf('/config/%s.neon', $configFile)); | ||
} | ||
|
||
return $config->createContainer(); | ||
} | ||
|
||
} | ||
|
||
(new SentryExtensionTest())->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,8 @@ | ||
php: | ||
date.timezone: Europe/Prague | ||
|
||
extensions: | ||
sentry: GrandMedia\Sentry\DI\SentryExtension | ||
|
||
sentry: | ||
dsn: 'https://[email protected]/1' |
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,16 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Tester\Environment; | ||
use Tester\Helpers; | ||
|
||
if (@!include __DIR__ . '/../vendor/autoload.php') { | ||
echo 'Install Nette Tester using `composer update --dev`'; | ||
exit(1); | ||
} | ||
|
||
\define('TEMP_DIR', __DIR__ . '/tmp/' . (isset($_SERVER['argv']) ? \md5(\serialize($_SERVER['argv'])) : \getmypid())); | ||
// create temporary directory | ||
Helpers::purge(\TEMP_DIR); | ||
|
||
// configure environment | ||
Environment::setup(); |
Empty file.