-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from johnkhansrc/refactor/validation_service_in…
…jection Refactor/validation service injection
- Loading branch information
Showing
38 changed files
with
268 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
https://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<!-- <defaults autowire="true" autoconfigure="true"/>--> | ||
<!-- <prototype namespace="Johnkhansrc\" resource="../../../src/*" exclude="../../../src/{DependencyInjection,Entity,Tests,Kernel.php}"/>--> | ||
|
||
<service id="johnkhansrc_iaphub.iaphub_http_client_validation_service" class="Johnkhansrc\IaphubBundle\Service\IaphubHttpClientValidationService" public="true"/> | ||
<service id="johnkhansrc_iaphub.iaphub_webhook_request_validator_service" class="Johnkhansrc\IaphubBundle\Service\IaphubWebhookRequestValidatorService" public="true" /> | ||
<service id="johnkhansrc_iaphub.webhook_factory" class="Johnkhansrc\IaphubBundle\Factory\WebhookFactory" /> | ||
<service id="symfony.http_client" class="Johnkhansrc\IaphubBundle\Tests\Mocks\FakeHTTPCLient" /> | ||
|
||
<service id="johnkhansrc_iaphub.iaphub_webhook_entrypoint_controller" class="Johnkhansrc\IaphubBundle\Controller\IaphubWebhookEntrypointController" public="true"> | ||
<argument key="$webhookFactory" type="service" id="johnkhansrc_iaphub.webhook_factory" /> | ||
<argument key="$eventDispatcher" type="service" id="event_dispatcher" on-invalid="null" /> | ||
<argument key="$requestValidator" type="service" id="johnkhansrc_iaphub.iaphub_webhook_request_validator_service" /> | ||
</service> | ||
|
||
<service id="johnkhansrc_iaphub.iaphub_http_client_service" class="Johnkhansrc\IaphubBundle\Service\IaphubHttpClientService" public="true" > | ||
<argument key="$iaphubHttpClientValidationService" type="service" id="johnkhansrc_iaphub.iaphub_http_client_validation_service"/> | ||
<argument key="$client" type="service" id="symfony.http_client"/> | ||
</service> | ||
|
||
<service id="johnkhansrc_iaphub.iaphub" class="Johnkhansrc\IaphubBundle\Iaphub" public="true" > | ||
<argument key="$iaphubHttpClient" type="service" id="johnkhansrc_iaphub.iaphub_http_client_service"/> | ||
</service> | ||
|
||
<service id="Johnkhansrc\IaphubBundle\Iaphub" alias="johnkhansrc_iaphub.iaphub" public="false" /> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Johnkhansrc\IaphubBundle\Tests; | ||
|
||
use Johnkhansrc\IaphubBundle\Service\IaphubHttpClientService; | ||
use Johnkhansrc\IaphubBundle\Tests\Mocks\FakeHTTPCLient; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
|
||
class IaphubHttpClientServiceTest extends TestCase | ||
{ | ||
private JohnkhansrcIaphubTestingKernel $kernel; | ||
private ContainerInterface $container; | ||
private IaphubHttpClientService $httpClientService; | ||
private HttpClientInterface $clientMock; | ||
|
||
public function setUp(): void | ||
{ | ||
$kernel = new JohnkhansrcIaphubTestingKernel([ | ||
'apikey' => 'foo', | ||
'webhook_auth_token' => 'bar', | ||
]); | ||
$kernel->boot(); | ||
$container = $kernel->getContainer(); | ||
|
||
/** @var IaphubHttpClientService $httpClientService */ | ||
$httpClientService = $container->get('johnkhansrc_iaphub.iaphub_http_client_service'); | ||
|
||
$this->kernel = $kernel; | ||
$this->container = $container; | ||
$this->httpClientService = $httpClientService; | ||
$this->clientMock = $httpClientService->getClient(); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testClientIsMocked(): void | ||
{ | ||
self::assertInstanceOf(FakeHTTPCLient::class, $this->clientMock); | ||
} | ||
|
||
public function testGetApikey(): void | ||
{ | ||
self::assertEquals('foo', $this->httpClientService->getApikey()); | ||
} | ||
} |
Oops, something went wrong.