Skip to content

Commit 42c2de2

Browse files
authored
Merge pull request #29 from mglaman/test-with-drupal
Attempt to add basic integration testing
2 parents 57d4c14 + c7b5786 commit 42c2de2

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@ php:
77
before_script:
88
- if php --ri xdebug >/dev/null; then phpenv config-rm xdebug.ini; fi
99
before_install:
10-
- composer self-update
1110
- composer global require "hirak/prestissimo:^0.3"
1211
install:
1312
- composer install --no-interaction
1413
script:
14+
# Inspections
1515
- ./vendor/bin/phpcs src
1616
- ./vendor/bin/phpstan analyze src
17+
18+
# Try to add to a Drupal setup.
19+
- composer create-project drupal-composer/drupal-project:8.x-dev $TRAVIS_BUILD_DIR/../drupal --no-interaction
20+
- cd $TRAVIS_BUILD_DIR/../drupal
21+
22+
# Install dependency.
23+
- composer config repositories.0 path $TRAVIS_BUILD_DIR
24+
- cat composer.json
25+
- composer require mglaman/phpstan-drupal *@dev
26+
- cp $TRAVIS_BUILD_DIR/tests/fixtures/drupal-phpstan.neon phpstan.neon
27+
- ./vendor/bin/phpstan analyze web/core/install.php
28+
1729
cache:
1830
directories:
1931
- $HOME/.composer/cache

src/DependencyInjection/DrupalExtension.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ public function loadConfiguration(): void
120120
// Prevent \Nette\DI\ContainerBuilder::completeStatement from array_walk_recursive into the arguments
121121
// and thinking these are real services for PHPStan's container.
122122
if (isset($serviceDefinition['arguments']) && is_array($serviceDefinition['arguments'])) {
123-
array_walk($serviceDefinition['arguments'], function (string &$argument) : void {
124-
$argument = str_replace('@', '', $argument);
123+
array_walk($serviceDefinition['arguments'], function (&$argument) : void {
124+
if (is_array($argument)) {
125+
// @todo fix for @http_kernel.controller.argument_metadata_factory
126+
$argument = '';
127+
} else {
128+
$argument = str_replace('@', '', $argument);
129+
}
125130
});
126131
}
127132
unset($serviceDefinition['tags']);

tests/fixtures/drupal-phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
excludes_analyse:
3+
- *Test.php
4+
- *TestBase.php
5+
level: 0
6+
includes:
7+
- vendor/mglaman/phpstan-drupal/extension.neon

0 commit comments

Comments
 (0)