Skip to content

Commit

Permalink
Fix: allow Drupal integration to be loaded with PHP 5 and 8 (#37)
Browse files Browse the repository at this point in the history
* Enable Drupal integration for other PHP major versions

* Fix unit tests for Drupal

* Fix Drupal 7 tests syntax for php 5

* Enable Drupal integration for php8

* Run Drupal 7 tests last for php5
  • Loading branch information
seemk authored Aug 15, 2021
1 parent 8f5a6f3 commit 559e453
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ TEST_WEB_56 := \
test_web_wordpress_48 \
test_web_wordpress_55 \
test_web_zend_1 \
test_web_drupal_7 \
test_web_custom

TEST_INTEGRATIONS_70 := \
Expand Down Expand Up @@ -465,6 +466,7 @@ TEST_WEB_73 := \
test_web_yii_2 \
test_web_zend_1 \
test_web_custom \
test_web_drupal_7 \
test_web_drupal_89

TEST_INTEGRATIONS_74 := \
Expand Down Expand Up @@ -501,6 +503,7 @@ TEST_WEB_74 := \
test_web_yii_2 \
test_web_zend_1 \
test_web_custom \
test_web_drupal_7 \
test_web_drupal_89

# NOTE: test_integrations_phpredis5 is not included in the PHP 8.0 integrations tests because of this bug that only
Expand Down
9 changes: 4 additions & 5 deletions src/DDTrace/Integrations/IntegrationsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function __construct(array $integrations)
'\DDTrace\Integrations\Mysqli\MysqliIntegration';
$this->integrations[SymfonyIntegration::NAME] =
'\DDTrace\Integrations\Symfony\SymfonyIntegration';
$this->integrations[DrupalIntegration::NAME] =
'\DDTrace\Integrations\Drupal\DrupalIntegration';
return;
}

Expand All @@ -96,11 +98,8 @@ public function __construct(array $integrations)
'\DDTrace\Integrations\Symfony\SymfonyIntegration';
$this->integrations[ZendFrameworkIntegration::NAME] =
'\DDTrace\Integrations\ZendFramework\ZendFrameworkIntegration';

if (\PHP_MAJOR_VERSION == 7) {
$this->integrations[DrupalIntegration::NAME] =
'\DDTrace\Integrations\Drupal\DrupalIntegration';
}
$this->integrations[DrupalIntegration::NAME] =
'\DDTrace\Integrations\Drupal\DrupalIntegration';

// For PHP 7.0+ use C level deferred integration loader
if (\PHP_MAJOR_VERSION < 7) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Integrations/Drupal/V7/CommonScenariosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testSuccessfulRequest()
[
SpanAssertion::exists('module_invoke', 'system_cron')->withChildren(array_merge(
array_fill(0, 15, SpanAssertion::exists('PDO.prepare')),
array_fill(0, 15, SpanAssertion::exists('PDOStatement.execute')),
array_fill(0, 15, SpanAssertion::exists('PDOStatement.execute'))
)),
SpanAssertion::exists('module_invoke', 'search_cron')->withChildren([
SpanAssertion::exists('PDO.prepare'),
Expand All @@ -103,7 +103,7 @@ public function testSuccessfulRequest()
]),
SpanAssertion::exists('module_invoke', 'field_cron')->withChildren(array_merge(
array_fill(0, 11, SpanAssertion::exists('PDO.prepare')),
array_fill(0, 11, SpanAssertion::exists('PDOStatement.execute')),
array_fill(0, 11, SpanAssertion::exists('PDOStatement.execute'))
)),
SpanAssertion::exists('module_invoke', 'dblog_cron')->withChildren([
SpanAssertion::exists('PDO.prepare'),
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Integrations/IntegrationsLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public function testWeDidNotForgetToRegisterALibraryForAutoLoading()
$excluded = [];
if (\PHP_MAJOR_VERSION < 7) {
$excluded[] = 'phpredis'; // PHP 7 only integration
$excluded[] = 'drupal';
} else {
// Deferred loading integrations
$excluded[] = 'elasticsearch';
Expand All @@ -175,7 +174,6 @@ public function testWeDidNotForgetToRegisterALibraryForAutoLoading()
$excluded[] = 'lumen';
$excluded[] = 'mongo';
$excluded[] = 'zendframework';
$excluded[] = 'drupal';
}
foreach ($excluded as $integrationToExclude) {
$index = array_search($integrationToExclude, $expected, true);
Expand Down

0 comments on commit 559e453

Please sign in to comment.