Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); /** * Passbolt ~ Open source password manager for teams ..

Decoded Output download

<?php
declare(strict_types=1);

/**
 * Passbolt ~ Open source password manager for teams
 * Copyright (c) Passbolt SA (https://www.passbolt.com)
 *
 * Licensed under GNU Affero General Public License version 3 of the or any later version.
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Passbolt SA (https://www.passbolt.com)
 * @license       https://opensource.org/licenses/AGPL-3.0 AGPL License
 * @link          https://www.passbolt.com Passbolt(tm)
 * @since         3.2.0
 */

namespace Passbolt\Locale\Test\TestCase\Service;

use App\Test\Factory\UserFactory;
use Cake\TestSuite\TestCase;
use CakephpTestSuiteLight\Fixture\TruncateDirtyTables;
use Passbolt\Locale\Service\GetOrgLocaleService;
use Passbolt\Locale\Service\GetUserLocaleService;
use Passbolt\Locale\Test\Factory\LocaleSettingFactory;
use Passbolt\Locale\Test\Lib\DummySystemLocaleTestTrait;

class GetUserLocaleServiceTest extends TestCase
{
    use DummySystemLocaleTestTrait;
    use TruncateDirtyTables;

    public function setUp(): void
    {
        parent::setUp();
        $this->loadPlugins(['Passbolt/Locale' => []]);
        $this->addFooSystemLocale();
    }

    public function tearDown(): void
    {
        GetOrgLocaleService::clearOrganisationLocale();
        $this->removeFooSystemLocale();
        parent::tearDown();
    }

    public function dataForTestGetUserLocaleServiceGetLocale(): array
    {
        return [
            ['[email protected]', 'fr-FR'],
            ['[email protected]', 'foo'],
            ['i_am_not_an_email', 'foo'],
            ['', 'foo'],
        ];
    }

    /**
     * @param string $recipient The email's recipient
     * @param string $expected
     * @throws \Exception
     * @dataProvider dataForTestGetUserLocaleServiceGetLocale
     */
    public function testGetUserLocaleServiceGetLocaleInEmail(string $recipient, string $expected): void
    {
        UserFactory::make(['username' => $recipient])
            ->withLocale('fr-FR')
            ->persist();

        LocaleSettingFactory::make()->locale('foo')->persist();

        $service = new GetUserLocaleService();

        $this->assertSame(
            $expected,
            $service->getLocale('[email protected]')
        );
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php
declare(strict_types=1);

/**
 * Passbolt ~ Open source password manager for teams
 * Copyright (c) Passbolt SA (https://www.passbolt.com)
 *
 * Licensed under GNU Affero General Public License version 3 of the or any later version.
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Passbolt SA (https://www.passbolt.com)
 * @license       https://opensource.org/licenses/AGPL-3.0 AGPL License
 * @link          https://www.passbolt.com Passbolt(tm)
 * @since         3.2.0
 */

namespace Passbolt\Locale\Test\TestCase\Service;

use App\Test\Factory\UserFactory;
use Cake\TestSuite\TestCase;
use CakephpTestSuiteLight\Fixture\TruncateDirtyTables;
use Passbolt\Locale\Service\GetOrgLocaleService;
use Passbolt\Locale\Service\GetUserLocaleService;
use Passbolt\Locale\Test\Factory\LocaleSettingFactory;
use Passbolt\Locale\Test\Lib\DummySystemLocaleTestTrait;

class GetUserLocaleServiceTest extends TestCase
{
    use DummySystemLocaleTestTrait;
    use TruncateDirtyTables;

    public function setUp(): void
    {
        parent::setUp();
        $this->loadPlugins(['Passbolt/Locale' => []]);
        $this->addFooSystemLocale();
    }

    public function tearDown(): void
    {
        GetOrgLocaleService::clearOrganisationLocale();
        $this->removeFooSystemLocale();
        parent::tearDown();
    }

    public function dataForTestGetUserLocaleServiceGetLocale(): array
    {
        return [
            ['[email protected]', 'fr-FR'],
            ['[email protected]', 'foo'],
            ['i_am_not_an_email', 'foo'],
            ['', 'foo'],
        ];
    }

    /**
     * @param string $recipient The email's recipient
     * @param string $expected
     * @throws \Exception
     * @dataProvider dataForTestGetUserLocaleServiceGetLocale
     */
    public function testGetUserLocaleServiceGetLocaleInEmail(string $recipient, string $expected): void
    {
        UserFactory::make(['username' => $recipient])
            ->withLocale('fr-FR')
            ->persist();

        LocaleSettingFactory::make()->locale('foo')->persist();

        $service = new GetUserLocaleService();

        $this->assertSame(
            $expected,
            $service->getLocale('[email protected]')
        );
    }
}

Function Calls

None

Variables

None

Stats

MD5 436e17f29e06057b22e4e066203c2dbd
Eval Count 0
Decode Time 84 ms