Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Mar 10, 2021
2 parents 3167454 + 04651cc commit 1fb6fbd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Component\HttpFoundation\Request;

// Get global config.php settings

if (!file_exists(__DIR__ . '/config.php')) {
if (!symlink(__DIR__ . '/config.php-DEVELOPMENT', __DIR__ . '/config.php')) {
throw new \RuntimeException('Could not symlink config.php-DEVELOPMENT to config.php. Copy config.php-DEVELOPMENT to config.php and customize it to your needs.');
Expand All @@ -24,4 +28,8 @@
// Enables old code which still extends non namespaced TestCase to work
class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');

// Register ClockMock for Request class before any tests are run
// https://github.com/symfony/symfony/issues/28259
ClockMock::register(Request::class);

require_once __DIR__ . '/vendor/autoload.php';
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use eZ\Bundle\EzPublishCoreBundle\EventListener\OriginalRequestListener;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
Expand Down Expand Up @@ -55,6 +56,8 @@ public function testOnKernelRequestNoOriginalRequest()

public function testOnKernelRequestWithOriginalRequest()
{
ClockMock::withClockMock(true);

$scheme = 'http';
$host = 'phoenix-rises.fm';
$port = 1234;
Expand All @@ -77,5 +80,7 @@ public function testOnKernelRequestWithOriginalRequest()
$listener = new OriginalRequestListener();
$listener->onKernelRequest($event);
$this->assertEquals($expectedOriginalRequest, $request->attributes->get('_ez_original_request'));

ClockMock::withClockMock(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use eZ\Publish\Core\MVC\Symfony\SiteAccess;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -90,6 +91,8 @@ public function testOnKernelRequestForwardSubRequest()

public function testOnKernelRequestForward()
{
ClockMock::withClockMock(true);

$queryParameters = ['some' => 'thing'];
$cookieParameters = ['cookie' => 'value'];
$request = Request::create('/test_sa/foo/bar', 'GET', $queryParameters, $cookieParameters);
Expand All @@ -113,6 +116,8 @@ public function testOnKernelRequestForward()
$this->requestEventListener->onKernelRequestForward($event);
$this->assertSame($response, $event->getResponse());
$this->assertTrue($event->isPropagationStopped());

ClockMock::withClockMock(false);
}

public function testOnKernelRequestRedirectSubRequest()
Expand Down
1 change: 1 addition & 0 deletions phpunit-integration-legacy-solr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<env name="CORES_SETUP" value="dedicated" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
<testsuites>
<testsuite name="eZ\Publish\API\Repository">
Expand Down
1 change: 1 addition & 0 deletions phpunit-integration-legacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<env name="fixtureDir" value="Legacy" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
<testsuites>
<testsuite name="eZ\Publish\API\Repository">
Expand Down

0 comments on commit 1fb6fbd

Please sign in to comment.