Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.github export-ignore
/tests export-ignore
/phpunit.xml.dist export-ignore
59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
48 changes: 48 additions & 0 deletions tests/DependencyInjection/HubSpotBundleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace DocPlanner\Bundle\HubSpotBundle\Tests\DependencyInjection;

use DocPlanner\Bundle\HubSpotBundle\HubSpotBundle;
use DocPlanner\Bundle\HubSpotBundle\Services\ProxyAwareFactory;
use DocPlanner\Bundle\HubSpotBundle\Services\ProxyClient;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;

final class HubSpotBundleTest extends TestCase
{
public function testProxyConfiguredServiceBuilds(): void
{
$bundle = new HubSpotBundle();
$container = new ContainerBuilder();
$container->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);
}
}
Loading