diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cb445a2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +/.github export-ignore +/tests export-ignore +/phpunit.xml.dist export-ignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..8e50e21 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,59 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +jobs: + tests: + name: PHP ${{ matrix.php }}, ${{ matrix.name }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: lowest deps + php: '7.4' + flags: --prefer-lowest --prefer-stable + - name: Symfony 3.4 + php: '7.4' + pins: symfony/config:3.4.* symfony/dependency-injection:3.4.* symfony/http-kernel:3.4.* symfony/yaml:3.4.* + - name: Symfony 4.4 + php: '7.4' + pins: symfony/config:4.4.* symfony/dependency-injection:4.4.* symfony/http-kernel:4.4.* symfony/yaml:4.4.* + - name: Symfony 4.4 + php: '8.1' + pins: symfony/config:4.4.* symfony/dependency-injection:4.4.* symfony/http-kernel:4.4.* symfony/yaml:4.4.* + - name: Symfony 5.4 + php: '8.1' + pins: symfony/config:5.4.* symfony/dependency-injection:5.4.* symfony/http-kernel:5.4.* symfony/yaml:5.4.* + - name: Symfony 6.4 + php: '8.2' + pins: symfony/config:6.4.* symfony/dependency-injection:6.4.* symfony/http-kernel:6.4.* symfony/yaml:6.4.* + - name: latest deps + php: '8.3' + env: + PINS: ${{ matrix.pins }} + COMPOSER_NO_SECURITY_BLOCKING: 1 + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + + - name: Install dependencies + run: | + if [ -n "$PINS" ]; then composer require --no-update --no-interaction $PINS; fi + composer update --no-interaction --no-progress ${{ matrix.flags }} + composer show | grep -E '^(hubspot/hubspot-php|symfony/(config|dependency-injection|http-kernel|yaml)) ' + + - name: PHPUnit + run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index 8e39caf..046ad63 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,10 @@ ], "require": { "php": "^7.4 || ^8.0", - "symfony/dependency-injection": "^2.8 || ^3.0 || ^4.0", - "symfony/config": "^2.8 || ^3.0 || ^4.0", - "symfony/http-kernel": "^2.8 || ^3.0 || ^4.0", + "symfony/dependency-injection": "^2.8 || ^3.0 || ^4.0 || ^5.4 || ^6.4", + "symfony/config": "^2.8 || ^3.0 || ^4.0 || ^5.4 || ^6.4", + "symfony/http-kernel": "^2.8 || ^3.0 || ^4.0 || ^5.4 || ^6.4", + "symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.4 || ^6.4", "hubspot/hubspot-php": "^3.1" }, "require-dev": { diff --git a/tests/DependencyInjection/HubSpotBundleTest.php b/tests/DependencyInjection/HubSpotBundleTest.php new file mode 100644 index 0000000..8a155a1 --- /dev/null +++ b/tests/DependencyInjection/HubSpotBundleTest.php @@ -0,0 +1,48 @@ +registerExtension($bundle->getContainerExtension()); + $container->loadFromExtension('hub_spot', [ + 'key' => 'legacy-key', + 'proxy' => [ + 'custom_url' => 'https://proxy.example.com/hubspot-gateway', + 'custom_headers' => ['x-api-key' => 'test-api-key', 'Authorization' => 'Bearer token'], + ], + ]); + $bundle->build($container); + $container->addCompilerPass(new PublicHubSpotPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION); + $container->compile(); + + self::assertStringContainsString('class HubSpotTestContainer', (new PhpDumper($container))->dump(['class' => 'HubSpotTestContainer'])); + + $factory = $container->get('hubspot'); + self::assertInstanceOf(ProxyAwareFactory::class, $factory); + $client = new \ReflectionProperty(ProxyAwareFactory::class, 'client'); + $client->setAccessible(true); + self::assertInstanceOf(ProxyClient::class, $client->getValue($factory)); + } +} + +final class PublicHubSpotPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + $container->getDefinition('hubspot')->setPublic(true); + } +}