aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php
diff options
context:
space:
mode:
authorPetr Pchelko <ppchelko@wikimedia.org>2020-12-07 13:00:14 -0600
committerPetr Pchelko <ppchelko@wikimedia.org>2020-12-09 16:36:07 -0600
commit1162411d7f475cfc30b55dc646cd613a9240072d (patch)
treea27e4aa3fde4fb3e5cbd2fef511fb430bc4b4577 /tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php
parent2b7dac53f3ac38e36a69854160ea981e43bdb7f2 (diff)
downloadmediawikicore-1162411d7f475cfc30b55dc646cd613a9240072d.tar.gz
mediawikicore-1162411d7f475cfc30b55dc646cd613a9240072d.zip
Make /page/{title}/html emit etags in RESTBase format
RESTBase used to emit ETag in the `"<rev_id>/<render_id>" format. For the benefit of the clients, preserve the formar. Render ID is a UUIDv1 uniquely identifying the ParserOutput. In future it would be used as a stashing key for stash deduplication. At this time I decided to just attach the render ID as extension data to our fake ParserOutput. Once we integrate Parsoid more into core, we will likely move it into a ParserOutput property, or even replace CacheTime::mCacheTime with a UUIDv1, but it's too early for that. Bug: T268234 Change-Id: Ie604e9c98021d59eb1a17ca65f227e8f234a45be
Diffstat (limited to 'tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php')
-rw-r--r--tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php b/tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php
index f06d6b1c2f58..b3c8f3235a97 100644
--- a/tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php
+++ b/tests/phpunit/integration/includes/Rest/Handler/PageHTMLHandlerTest.php
@@ -84,7 +84,8 @@ class PageHTMLHandlerTest extends MediaWikiIntegrationTestCase {
new NullStatsdDataFactory(),
new NullLogger()
),
- $this->getServiceContainer()->getWikiPageFactory()
+ $this->getServiceContainer()->getWikiPageFactory(),
+ $this->getServiceContainer()->getGlobalIdGenerator()
);
if ( $parsoid !== null ) {
@@ -187,13 +188,15 @@ class PageHTMLHandlerTest extends MediaWikiIntegrationTestCase {
// First, test it works if nothing was cached yet.
// Make some time pass since page was created:
- MWTimestamp::setFakeTime( $time + 10 );
+ $time += 10;
+ MWTimestamp::setFakeTime( $time );
$handler = $this->newHandler( $cache );
$response = $this->executeHandler( $handler, $request, [
'format' => 'html'
] );
$this->assertArrayHasKey( 'ETag', $response->getHeaders() );
$etag = $response->getHeaderLine( 'ETag' );
+ $this->assertStringMatchesFormat( '"' . $page->getLatest() . '/%x-%x-%x-%x-%x"', $etag );
$this->assertArrayHasKey( 'Last-Modified', $response->getHeaders() );
$this->assertSame( MWTimestamp::convert( TS_RFC2822, $time ),
$response->getHeaderLine( 'Last-Modified' ) );
@@ -204,10 +207,11 @@ class PageHTMLHandlerTest extends MediaWikiIntegrationTestCase {
'format' => 'html'
] );
$this->assertArrayHasKey( 'ETag', $response->getHeaders() );
- $this->assertNotSame( $etag, $response->getHeaderLine( 'ETag' ) );
+ $this->assertSame( $etag, $response->getHeaderLine( 'ETag' ) );
$etag = $response->getHeaderLine( 'ETag' );
+ $this->assertStringMatchesFormat( '"' . $page->getLatest() . '/%x-%x-%x-%x-%x"', $etag );
$this->assertArrayHasKey( 'Last-Modified', $response->getHeaders() );
- $this->assertSame( MWTimestamp::convert( TS_RFC2822, $time + 10 ),
+ $this->assertSame( MWTimestamp::convert( TS_RFC2822, $time ),
$response->getHeaderLine( 'Last-Modified' ) );
// Now, expire the cache
@@ -225,6 +229,8 @@ class PageHTMLHandlerTest extends MediaWikiIntegrationTestCase {
] );
$this->assertArrayHasKey( 'ETag', $response->getHeaders() );
$this->assertNotSame( $etag, $response->getHeaderLine( 'ETag' ) );
+ $etag = $response->getHeaderLine( 'ETag' );
+ $this->assertStringMatchesFormat( '"' . $page->getLatest() . '/%x-%x-%x-%x-%x"', $etag );
$this->assertArrayHasKey( 'Last-Modified', $response->getHeaders() );
$this->assertSame( MWTimestamp::convert( TS_RFC2822, $time ),
$response->getHeaderLine( 'Last-Modified' ) );