Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Fix tagging services
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Nov 4, 2020
1 parent 162298a commit 4eeff2c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 43 deletions.
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,3 @@ parameters:
count: 1
path: src/Manager/StaticServiceManager.php

-
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Client not found\\.$#"
count: 1
path: tests/Action/BackendActionIntegrationTest.php

-
message: "#^Call to method request\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Client\\.$#"
count: 1
path: tests/Action/BackendActionIntegrationTest.php

-
message: "#^Call to method getResponse\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Client\\.$#"
count: 1
path: tests/Action/BackendActionIntegrationTest.php

1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php">
<php>
<server name="KERNEL_CLASS" value="Nucleos\ShariffBundle\Tests\App\AppKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>
<testsuites>
Expand Down
13 changes: 6 additions & 7 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->load('Nucleos\\ShariffBundle\\Service\\', '../../Service')
->exclude('../../Service/{Exception}')
->public()
->autowire()
->autoconfigure()
;

$services
->load('Nucleos\\ShariffBundle\\Service\\', '../../Service')
->exclude('../../Service/{Exception,Facebook}')
->public()
->tag('nucleos.shariff')

->set(Facebook::class)
->public()
->tag('nucleos.shariff')
->args([
new Parameter('nucleos_shariff.service.facebook.app_id'),
Expand Down
8 changes: 4 additions & 4 deletions src/Service/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Facebook implements Service
/**
* @var string
*/
private $appid;
private $appId;

/**
* @var string
Expand All @@ -33,9 +33,9 @@ final class Facebook implements Service
*/
private $version;

public function __construct(string $appid, string $secret, ?string $version = null)
public function __construct(string $appId, string $secret, ?string $version = null)
{
$this->appid = $appid;
$this->appId = $appId;
$this->secret = $secret;
$this->version = $version;
}
Expand All @@ -47,7 +47,7 @@ public function getCode(): string

public function createRequest(RequestFactoryInterface $factory, string $url): RequestInterface
{
$accessToken = urlencode($this->appid).'|'.urlencode($this->secret);
$accessToken = urlencode($this->appId).'|'.urlencode($this->secret);

$query = sprintf(
'https://graph.facebook.com/%s?id=%s&fields=engagement&access_token=%s',
Expand Down
24 changes: 12 additions & 12 deletions tests/Action/BackendActionIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@

namespace Nucleos\ShariffBundle\Tests\Action;

use Nucleos\ShariffBundle\Tests\App\AppKernel;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Component\HttpKernel\Client;
use Nucleos\ShariffBundle\Manager\ServiceManager;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

final class BackendActionIntegrationTest extends TestCase
final class BackendActionIntegrationTest extends WebTestCase
{
public function testStartup(): void
public function testShare(): void
{
if (class_exists(KernelBrowser::class)) {
$client = new KernelBrowser(new AppKernel());
} else {
$client = new Client(new AppKernel());
}

$client = static::createClient();
$client->request('GET', '/share');

static::assertSame(200, $client->getResponse()->getStatusCode());

$container = static::$kernel->getContainer();
$serviceManager = $container->get('test_service_manager');

\assert($serviceManager instanceof ServiceManager);

static::assertCount(8, $serviceManager->getAll());
}
}
16 changes: 11 additions & 5 deletions tests/App/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
framework:
secret: secret
test: true

cache:
pools:
cache.shariff:
adapter: cache.adapter.filesystem

session:
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/sessions/%kernel.environment%'
cookie_secure: auto
cookie_samesite: lax
storage_id: session.storage.mock_file

twig:
paths:
Expand All @@ -21,12 +19,20 @@ nucleos_shariff:
http_client: 'symfony_http_client'
request_factory: 'nyholm.psr7.psr17_factory'

services:
facebook:
app_id: 'foo_id'
secret: 'app_secret'
version: 1.0'

services:
_defaults:
public: false
public: true

symfony_http_client:
class: Symfony\Component\HttpClient\Psr18Client

nyholm.psr7.psr17_factory:
class: Nyholm\Psr7\Factory\Psr17Factory

test_service_manager: '@Nucleos\ShariffBundle\Manager\ServiceManager'

0 comments on commit 4eeff2c

Please sign in to comment.