Skip to content

Commit

Permalink
Merge pull request #585 from alcaeus/fix-wrong-interface
Browse files Browse the repository at this point in the history
Fix wrong interface inheritance in command logger
  • Loading branch information
alcaeus authored Sep 30, 2019
2 parents e95d3e8 + 0526d48 commit 227d908
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 31 deletions.
4 changes: 2 additions & 2 deletions APM/PSRCommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace Doctrine\Bundle\MongoDBBundle\APM;

use Doctrine\ODM\MongoDB\APM\CommandLoggerInterface;
use MongoDB\Driver\Monitoring\CommandFailedEvent;
use MongoDB\Driver\Monitoring\CommandStartedEvent;
use MongoDB\Driver\Monitoring\CommandSubscriber;
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
use Psr\Log\LoggerInterface;
use function json_encode;
use function MongoDB\Driver\Monitoring\addSubscriber;
use function MongoDB\Driver\Monitoring\removeSubscriber;

final class PSRCommandLogger implements CommandSubscriber
final class PSRCommandLogger implements CommandLoggerInterface
{
/** @var bool */
private $registered = false;
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG for 4.0.x
===================

4.0.0-RC3 (2019-09-30)
----------------------

All issues and pull requests in this release may be found under the [4.0.0-RC3 milestone](https://github.com/doctrine/DoctrineMongoDBBundle/issues?q=milestone%3A4.0.0-RC3).

- [585: Fix wrong interface inheritance in command logger](https://github.com/doctrine/DoctrineMongoDBBundle/pull/585) thanks to @alcaeus and @lljaworski

4.0.0-RC2 (2019-09-24)
----------------------

Expand Down
58 changes: 34 additions & 24 deletions Tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,41 @@ public function testLoggerConfig(bool $expected, array $config, bool $debug)

$definition = $this->container->getDefinition('doctrine_mongodb.odm.command_logger');
$this->assertSame($expected, $definition->hasTag('doctrine_mongodb.odm.command_logger'));

$this->container->compile();

// Fetch the command logger registry to make sure the appropriate number of services has been registered
$this->container->get('doctrine_mongodb.odm.command_logger_registry');
}

public function provideLoggerConfigs()
{
$config = ['connections' => ['default' => []]];

return [
[
'Debug mode enabled' => [
// Logging is always enabled in debug mode
true,
[
'expected' => true,
'config' => [
'document_managers' => ['default' => []],
] + $config,
true,
'debug' => true,
],
[
'Debug mode disabled' => [
// Logging is disabled by default when not in debug mode
false,
[
'expected' => false,
'config' => [
'document_managers' => ['default' => []],
] + $config,
false,
'debug' => false,
],
[
'Logging enabled by config' => [
// Logging can be enabled by config
true,
[
'expected' => true,
'config' => [
'document_managers' => ['default' => ['logging' => true]],
] + $config,
false,
'debug' => false,
],
];
}
Expand All @@ -94,36 +99,41 @@ public function testDataCollectorConfig(bool $expected, array $config, bool $deb

$dataCollectorDefinition = $this->container->getDefinition('doctrine_mongodb.odm.data_collector');
$this->assertSame($expected, $dataCollectorDefinition->hasTag('data_collector'));

$this->container->compile();

// Fetch the command logger registry to make sure the appropriate number of services has been registered
$this->container->get('doctrine_mongodb.odm.command_logger_registry');
}

public function provideDataCollectorConfigs()
{
$config = ['connections' => ['default' => []]];

return [
[
'Debug mode enabled' => [
// Profiling is always enabled in debug mode
true,
[
'expected' => true,
'config' => [
'document_managers' => ['default' => []],
] + $config,
true,
'debug' => true,
],
[
'Debug mode disabled' => [
// Profiling is disabled by default when not in debug mode
false,
[
'expected' => false,
'config' => [
'document_managers' => ['default' => []],
] + $config,
false,
'debug' => false,
],
[
'Profiling enabled by config' => [
// Profiling can be enabled by config
true,
[
'expected' => true,
'config' => [
'document_managers' => ['default' => ['profiler' => true]],
] + $config,
false,
'debug' => false,
],
];
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/DependencyInjection/AbstractMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ public function testLoadSimpleSingleConnection()
$this->assertArrayHasKey('typeMap', $arguments[2]);
$this->assertSame(['root' => 'array', 'document' => 'array'], $arguments[2]['typeMap']);

$definition = $container->getDefinition('doctrine_mongodb.odm.default_configuration');
$methodCalls = $definition->getMethodCalls();
$methodNames = array_map(static function ($call) {
$definition = $container->getDefinition('doctrine_mongodb.odm.default_configuration');
$methodCalls = $definition->getMethodCalls();
$methodNames = array_map(static function ($call) {
return $call[0];
}, $methodCalls);
$this->assertInternalType('integer', $pos = array_search('setDefaultDB', $methodNames));
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function testFactoriesAreRegistered()

public function testPublicServicesAndAliases()
{
$loader = new DoctrineMongoDBExtension();
$loader = new DoctrineMongoDBExtension();
$loader->load(self::buildConfiguration(), $container = $this->buildMinimalContainer());

$this->assertTrue($container->getDefinition('doctrine_mongodb')->isPublic());
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"require": {
"php": "^7.2",
"doctrine/annotations": "^1.2",
"doctrine/mongodb-odm": "^2.0.0-RC1",
"doctrine/mongodb-odm": "^2.0.0-RC2",
"psr/log": "^1.0",
"symfony/console": "^3.4 || ^4.0",
"symfony/dependency-injection": "^3.4 || ^4.0",
Expand All @@ -26,6 +26,7 @@
"doctrine/coding-standard": "^6.0",
"doctrine/data-fixtures": "^1.2.2",
"phpunit/phpunit": "^7.3",
"squizlabs/php_codesniffer": "^3.5",
"symfony/form": "^3.4 || ^4.0",
"symfony/phpunit-bridge": "^3.4 || ^4.0",
"symfony/yaml": "^3.4 || ^4.0"
Expand Down

0 comments on commit 227d908

Please sign in to comment.