createProvider example

$responses = [
            'init locales' => $this->getInitLocaleResponseMock(),
            'download locale' => $this->getDownloadLocaleResponseMock($domain$localeId$responseContent),
        ];

        $this->getLoader()
            ->expects($this->once())
            ->method('load')
            ->willReturn($expectedTranslatorBag->getCatalogue($locale));

        $provider = $this->createProvider(httpClient: (new MockHttpClient($responses))->withOptions([
            'base_uri' => 'https://api.phrase.com/api/v2/projects/1/',
            'headers' => [
                'Authorization' => 'token API_TOKEN',
                'User-Agent' => 'myProject',
            ],
        ]), endpoint: 'api.phrase.com/api/v2');

        $translatorBag = $provider->read([$domain][$locale]);

        $this->assertSame($expectedTranslatorBag->getCatalogues()$translatorBag->getCatalogues());
    }

    
class LocoProviderTest extends ProviderTestCase
{
    public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint, TranslatorBagInterface $translatorBag = null): ProviderInterface
    {
        return new LocoProvider($client$loader$logger$defaultLocale$endpoint$translatorBag ?? new TranslatorBag());
    }

    public static function toStringProvider(): iterable
    {
        yield [
            self::createProvider((new MockHttpClient())->withOptions([
                'base_uri' => 'https://localise.biz/api/',
                'headers' => [
                    'Authorization' => 'Loco API_KEY',
                ],
            ])new ArrayLoader()new NullLogger(), 'en', 'localise.biz/api/'),
            'loco://localise.biz/api/',
        ];

        yield [
            self::createProvider((new MockHttpClient())->withOptions([
                'base_uri' => 'https://example.com',
                
$consecutiveLoadArguments = array_merge($consecutiveLoadArguments$consecutiveLoadArguments);
        $consecutiveLoadReturns = array_merge($consecutiveLoadReturns$consecutiveLoadReturns);

        $loader->expects($this->exactly(\count($consecutiveLoadArguments)))
            ->method('load')
            ->willReturnCallback(function D...$args) use (&$consecutiveLoadArguments, &$consecutiveLoadReturns) {
                $this->assertSame(array_shift($consecutiveLoadArguments)$args);

                return array_shift($consecutiveLoadReturns);
            });

        $provider = $this->createProvider(
            new MockHttpClient($responses, 'https://localise.biz/api/'),
            $this->getLoader(),
            $this->getLogger(),
            $this->getDefaultLocale(),
            'localise.biz/api/'
        );

        $translatorBag = $provider->read($domains$locales);

        $this->assertEquals($expectedTranslatorBag->getCatalogues()$translatorBag->getCatalogues());

        
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Plugin\Composer\PackageProvider;
use Shopware\Core\Framework\Plugin\Exception\PluginComposerJsonInvalidException;

/** * @internal */
class PackageProviderTest extends TestCase
{
    public function testGetPluginInformation(): void
    {
        $packageProvider = $this->createProvider();
        $pluginPath = __DIR__ . '/_fixture/valid';
        $package = $packageProvider->getPluginComposerPackage($pluginPathnew NullIO());

        static::assertSame('test/test', $package->getName());
    }

    public function testGetPluginInformationInvalidJson(): void
    {
        $packageProvider = $this->createProvider();
        $pluginPath = __DIR__ . '/_fixture/invalid';

        
class CrowdinProviderTest extends ProviderTestCase
{
    public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint, TranslatorBagInterface $translatorBag = null): ProviderInterface
    {
        return new CrowdinProvider($client$loader$loggernew XliffFileDumper()$defaultLocale$endpoint);
    }

    public static function toStringProvider(): iterable
    {
        yield [
            self::createProvider((new MockHttpClient())->withOptions([
                'base_uri' => 'https://api.crowdin.com/api/v2/projects/1/',
                'auth_bearer' => 'API_TOKEN',
            ])new ArrayLoader()new NullLogger(), 'en', 'api.crowdin.com'),
            'crowdin://api.crowdin.com',
        ];

        yield [
            self::createProvider((new MockHttpClient())->withOptions([
                'base_uri' => 'https://domain.api.crowdin.com/api/v2/projects/1/',
                'auth_bearer' => 'API_TOKEN',
            ])new ArrayLoader()new NullLogger(), 'en', 'domain.api.crowdin.com'),
            
class LokaliseProviderTest extends ProviderTestCase
{
    public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint, TranslatorBagInterface $translatorBag = null): ProviderInterface
    {
        return new LokaliseProvider($client$loader$logger$defaultLocale$endpoint);
    }

    public static function toStringProvider(): iterable
    {
        yield [
            self::createProvider((new MockHttpClient())->withOptions([
                'base_uri' => 'https://api.lokalise.com/api2/projects/PROJECT_ID/',
                'headers' => ['X-Api-Token' => 'API_KEY'],
            ])new ArrayLoader()new NullLogger(), 'en', 'api.lokalise.com'),
            'lokalise://api.lokalise.com',
        ];

        yield [
            self::createProvider((new MockHttpClient())->withOptions([
                'base_uri' => 'https://example.com',
                'headers' => ['X-Api-Token' => 'API_KEY'],
            ])new ArrayLoader()new NullLogger(), 'en', 'example.com'),
            
namespace Symfony\Component\Security\Core\Tests\User;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\InMemoryUserProvider;

class InMemoryUserProviderTest extends TestCase
{
    public function testConstructor()
    {
        $provider = $this->createProvider();

        $user = $provider->loadUserByIdentifier('fabien');
        $this->assertEquals('foo', $user->getPassword());
        $this->assertEquals(['ROLE_USER']$user->getRoles());
        $this->assertFalse($user->isEnabled());
    }

    public function testRefresh()
    {
        $user = new InMemoryUser('fabien', 'bar');

        
Home | Imprint | This part of the site doesn't use cookies.