Skip to content

Commit b435492

Browse files
committed
update structure and tests
1 parent c025712 commit b435492

27 files changed

+66
-31
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
.idea
22
/coverage/
33
/vendor/
4-
/var/
5-
!/var/.gitkeep
64

75
composer.lock
86
clover.xml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/Resources/config/services.yml Resources/config/services.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ services:
1717
- { name: kernel.event_listener, event: kernel.exception }
1818

1919
symfony_rollbar.provider.rollbar_handler:
20+
public: true
2021
class: SymfonyRollbarBundle\Provider\RollbarHandler
2122
arguments: ["@service_container"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/Fixtures/app/AppKernel.php Tests/Fixtures/app/AppKernel.php

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace SymfonyRollbarBundle\Tests\Fixtures\app;
4+
35
use Symfony\Component\HttpKernel\Kernel;
46
use Symfony\Component\Config\Loader\LoaderInterface;
57

@@ -25,6 +27,8 @@ public function getRootDir()
2527

2628
/**
2729
* @param \Symfony\Component\Config\Loader\LoaderInterface $loader
30+
*
31+
* @throws \Exception
2832
*/
2933
public function registerContainerConfiguration(LoaderInterface $loader)
3034
{
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/SymfonyRollbarBundle/BundleTest.php Tests/SymfonyRollbarBundle/BundleTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
2-
namespace Tests\SymfonyRollbarBundle;
2+
namespace SymfonyRollbarBundle\Tests;
33

4+
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
45
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
56
use Symfony\Component\HttpFoundation\Request;
67
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
@@ -9,7 +10,7 @@
910

1011
/**
1112
* Class BundleTest
12-
* @package Tests\SymfonyRollbarBundle
13+
* @package SymfonyRollbarBundle\Tests
1314
*/
1415
class BundleTest extends KernelTestCase
1516
{
@@ -39,5 +40,7 @@ public function testListeners()
3940
$ok = $listener[0] instanceof $expected[0] || $listener[0] instanceof $expected[1];
4041
$this->assertTrue($ok, 'Listeners were not registered');
4142
}
43+
44+
restore_error_handler();
4245
}
4346
}

tests/SymfonyRollbarBundle/DependencyInjection/ConfigurationTest.php Tests/SymfonyRollbarBundle/DependencyInjection/ConfigurationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace Tests\SymfonyRollbarBundle\DependencyInjection;
3+
namespace SymfonyRollbarBundle\Tests\DependencyInjection;
44

55
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
66
use SymfonyRollbarBundle\DependencyInjection\Configuration;
77
use SymfonyRollbarBundle\DependencyInjection\SymfonyRollbarExtension;
88

99
/**
1010
* Class ConfigurationTest
11-
* @package Tests\SymfonyRollbarBundle\DependencyInjection
11+
* @package SymfonyRollbarBundle\Tests\DependencyInjection
1212
*/
1313
class ConfigurationTest extends KernelTestCase
1414
{

tests/SymfonyRollbarBundle/DependencyInjection/SymfonyRollbarExtensionTest.php Tests/SymfonyRollbarBundle/DependencyInjection/SymfonyRollbarExtensionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Tests\SymfonyRollbarBundle\DependencyInjection;
2+
namespace SymfonyRollbarBundle\Tests\DependencyInjection;
33

44
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
55
use SymfonyRollbarBundle\DependencyInjection\SymfonyRollbarExtension;
@@ -10,7 +10,7 @@
1010

1111
/**
1212
* Class SymfonyRollbarExtensionTest
13-
* @package Tests\SymfonyRollbarBundle\DependencyInjection
13+
* @package SymfonyRollbarBundle\Tests\DependencyInjection
1414
*/
1515
class SymfonyRollbarExtensionTest extends AbstractExtensionTestCase
1616
{

tests/SymfonyRollbarBundle/EventListener/AbstractListenerTest.php Tests/SymfonyRollbarBundle/EventListener/AbstractListenerTest.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Tests\SymfonyRollbarBundle\EventListener;
2+
namespace SymfonyRollbarBundle\Tests\EventListener;
33

44
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
55
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
@@ -10,7 +10,7 @@
1010

1111
/**
1212
* Class AbstractListenerTest
13-
* @package Tests\SymfonyRollbarBundle\EventListener
13+
* @package SymfonyRollbarBundle\Tests\EventListener
1414
*/
1515
class AbstractListenerTest extends KernelTestCase
1616
{
@@ -40,6 +40,8 @@ public function testListeners()
4040
$ok = $listener[0] instanceof $expected[0] || $listener[0] instanceof $expected[1];
4141
$this->assertTrue($ok, 'Listeners were not registered');
4242
}
43+
44+
restore_error_handler();
4345
}
4446

4547
/**
@@ -60,6 +62,9 @@ public function generatorGetSubscribedEvents()
6062
*/
6163
public function testGetSubscribedEvents($class)
6264
{
65+
$handler = set_error_handler('var_dump');
66+
restore_error_handler();
67+
6368
/**
6469
* @var AbstractListener $listener
6570
*/
@@ -72,6 +77,7 @@ public function testGetSubscribedEvents($class)
7277
$list = $listener::getSubscribedEvents();
7378

7479
$this->assertEquals($expect, $list);
80+
set_error_handler($handler);
7581
}
7682

7783
/**
@@ -81,6 +87,9 @@ public function testGetSubscribedEvents($class)
8187
*/
8288
public function testGetLogger($class)
8389
{
90+
$handler = set_error_handler('var_dump');
91+
restore_error_handler();
92+
8493
/**
8594
* @var AbstractListener $listener
8695
*/
@@ -89,5 +98,6 @@ public function testGetLogger($class)
8998

9099
$logger = $listener->getLogger();
91100
$this->assertTrue($logger instanceof \Monolog\Logger);
101+
set_error_handler($handler);
92102
}
93103
}

tests/SymfonyRollbarBundle/EventListener/ErrorListenerTest.php Tests/SymfonyRollbarBundle/EventListener/ErrorListenerTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Tests\SymfonyRollbarBundle\EventListener;
2+
namespace SymfonyRollbarBundle\Tests\EventListener;
33

44
use Monolog\Logger;
55
use Rollbar\ErrorWrapper;
@@ -10,7 +10,7 @@
1010

1111
/**
1212
* Class ErrorListenerTest
13-
* @package Tests\SymfonyRollbarBundle\EventListener
13+
* @package SymfonyRollbarBundle\Tests\EventListener
1414
*/
1515
class ErrorListenerTest extends KernelTestCase
1616
{
@@ -56,6 +56,7 @@ public function testUserError()
5656
}
5757

5858
trigger_error($message, E_USER_ERROR);
59+
restore_error_handler();
5960
}
6061

6162
/**
@@ -83,6 +84,7 @@ public function testFatalError()
8384

8485
$exception = $record['context']['exception'];
8586
$this->assertInstanceOf(ErrorWrapper::class, $exception);
87+
restore_error_handler();
8688
} catch (\Exception $e) {
8789
echo implode("\n", [
8890
$e->getMessage(),
@@ -102,7 +104,6 @@ public function testFatalError()
102104
$listener[0]->getLogger()->setHandlers([$handler]);
103105
}
104106

105-
// @ will allow to skip fatal error inside application, but we can get error with error_get_last()
106107
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
107108
$this->expectException('Error');
108109
$this->expectExceptionMessage('Call to undefined function this_is_fatal_error()');

tests/SymfonyRollbarBundle/EventListener/ExceptionListenerTest.php Tests/SymfonyRollbarBundle/EventListener/ExceptionListenerTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Tests\SymfonyRollbarBundle\EventListener;
2+
namespace SymfonyRollbarBundle\Tests\EventListener;
33

44
use Monolog\Logger;
55
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -11,7 +11,7 @@
1111

1212
/**
1313
* Class ExceptionListenerTest
14-
* @package Tests\SymfonyRollbarBundle\EventListener
14+
* @package SymfonyRollbarBundle\Tests\EventListener
1515
*/
1616
class ExceptionListenerTest extends KernelTestCase
1717
{
@@ -42,6 +42,7 @@ public function testException($exception)
4242
);
4343

4444
$eventDispatcher->dispatch('kernel.exception', $event);
45+
restore_error_handler();
4546
}
4647

4748
public function generateEventExceptions()

tests/SymfonyRollbarBundle/Provider/RollbarHandlerTest.php Tests/SymfonyRollbarBundle/Provider/RollbarHandlerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests\SymfonyRollbarBundle\Provider;
3+
namespace SymfonyRollbarBundle\Tests\Provider;
44

55
use Rollbar\Payload\Level;
66
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -9,7 +9,7 @@
99
/**
1010
* Class RollbarHandlerTest
1111
*
12-
* @package Tests\SymfonyRollbarBundle\Provider
12+
* @package SymfonyRollbarBundle\Tests\Provider
1313
*/
1414
class RollbarHandlerTest extends KernelTestCase
1515
{

tests/phpunit.xml Tests/phpunit.xml.dist

+13-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
66
backupGlobals="false"
77
colors="true"
8-
convertErrorsToExceptions="false"
9-
bootstrap="Fixtures/app/autoload.php"
8+
convertErrorsToExceptions="true"
9+
bootstrap="./Fixtures/app/autoload.php"
1010
>
11+
<listeners>
12+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
13+
</listeners>
14+
1115
<php>
1216
<ini name="error_reporting" value="-1" />
1317
<server name="KERNEL_DIR" value="Fixtures/app" />
18+
<server name="KERNEL_CLASS" value="SymfonyRollbarBundle\Tests\Fixtures\app\AppKernel" />
1419
</php>
1520

1621
<testsuites>
@@ -21,7 +26,12 @@
2126

2227
<filter>
2328
<whitelist>
24-
<directory>./../src</directory>
29+
<directory>.</directory>
30+
<exclude>
31+
<directory>./Resources</directory>
32+
<directory>./Tests</directory>
33+
<directory>./vendor</directory>
34+
</exclude>
2535
</whitelist>
2636
</filter>
2737
<logging>

composer.json

+18-11
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,37 @@
1010
}
1111
],
1212
"autoload": {
13-
"psr-4": { "SymfonyRollbarBundle\\": "src/" }
13+
"psr-4": { "SymfonyRollbarBundle\\": "./" },
14+
"exclude-from-classmap": [
15+
"/Tests/"
16+
]
1417
},
1518
"autoload-dev": {
16-
"psr-4": { "Tests\\": "tests/"}
19+
"psr-4": { "Tests\\": "Tests/"},
20+
"files": [
21+
"Tests/Fixtures/app/AppKernel.php"
22+
]
1723
},
1824
"require": {
1925
"php": ">=5.6",
20-
"monolog/monolog": "^1.22",
26+
"monolog/monolog": "^1.23",
2127
"rollbar/rollbar": "^1.3",
22-
"symfony/dependency-injection": "^3.2",
23-
"symfony/config": "^3.2",
24-
"symfony/http-kernel": "^3.2"
28+
"symfony/dependency-injection": "~3.0|~4.0",
29+
"symfony/config": "~3.0|~4.0",
30+
"symfony/http-kernel": "~3.0|~4.0"
2531
},
2632
"require-dev": {
27-
"phpunit/phpunit": "^5.7",
33+
"phpunit/phpunit": "^5.7 || ^6.5",
2834
"doctrine/doctrine-fixtures-bundle": "^2.3",
29-
"squizlabs/php_codesniffer": "^2.7",
30-
"matthiasnoback/symfony-dependency-injection-test": "^1.1"
35+
"squizlabs/php_codesniffer": "^3.2",
36+
"matthiasnoback/symfony-dependency-injection-test": "^1.2",
37+
"symfony/phpunit-bridge": "^4.0"
3138
},
3239
"scripts": {
3340
"test": [
3441
"composer install",
35-
"./vendor/bin/phpcs --standard=psr2 src/ tests/SymfonyRollbarBundle",
36-
"./vendor/bin/phpunit -c tests/"
42+
"./vendor/bin/phpcs --standard=psr2 DependencyInjection/ EventListener/ Provider/ Tests/SymfonyRollbarBundle",
43+
"./vendor/bin/phpunit -c Tests/phpunit.xml.dist"
3744
]
3845
}
3946
}

0 commit comments

Comments
 (0)