Skip to content

Commit 48b8250

Browse files
author
He, Joan(johe)
committed
Merge pull request #654 from magento-extensibility/MAGETWO-43258-wrong-links-on-multi-website-store
Magetwo 43258 wrong links on multi website store
2 parents 2e1580f + 7449799 commit 48b8250

File tree

5 files changed

+34
-24
lines changed

5 files changed

+34
-24
lines changed

app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class HttpPlugin
1919
*/
2020
public function beforeSendResponse(\Magento\Framework\App\Response\Http $subject)
2121
{
22+
if ($subject instanceof \Magento\MediaStorage\Model\File\Storage\Response) {
23+
return;
24+
}
2225
$subject->sendVary();
2326
}
2427
}

app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php

+19-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,27 @@
1212

1313
class HttpPluginTest extends \PHPUnit_Framework_TestCase
1414
{
15-
public function testBeforeSendResponse()
15+
/**
16+
* @param \Magento\Framework\App\Response\FileInterface $responseInstanceClass
17+
* @param int $sendVaryCalled
18+
*
19+
* @dataProvider beforeSendResponseDataProvider
20+
*/
21+
public function testBeforeSendResponse($responseInstanceClass, $sendVaryCalled)
1622
{
17-
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject $responseMock */
18-
$responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http')
19-
->disableOriginalConstructor()
20-
->getMock();
21-
$responseMock->expects($this->once())->method('sendVary');
23+
/** @var \Magento\Framework\App\Response\Http | \PHPUnit_Framework_MockObject_MockObject $responseMock */
24+
$responseMock = $this->getMock($responseInstanceClass, [], [], '', false);
25+
$responseMock->expects($this->exactly($sendVaryCalled))
26+
->method('sendVary');
2227
$plugin = new HttpPlugin();
2328
$plugin->beforeSendResponse($responseMock);
2429
}
30+
31+
public function beforeSendResponseDataProvider()
32+
{
33+
return [
34+
['Magento\Framework\App\Response\Http', 1],
35+
['Magento\MediaStorage\Model\File\Storage\Response', 0]
36+
];
37+
}
2538
}

app/code/Magento/PageCache/composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"magento/module-config": "1.0.0-beta3",
77
"magento/module-store": "1.0.0-beta3",
88
"magento/module-backend": "1.0.0-beta3",
9+
"magento/module-media-storage": "1.0.0-beta3",
910
"magento/framework": "1.0.0-beta3",
1011
"magento/magento-composer-installer": "*"
1112
},

lib/internal/Magento/Framework/App/PageCache/Identifier.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public function __construct(
4040
public function getValue()
4141
{
4242
$data = [
43-
$this->request->isSecure(),
44-
$this->request->getRequestUri(),
43+
$this->request->getUriString(),
4544
$this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING)
4645
?: $this->context->getVaryString()
4746
];

lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php

+10-16
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,15 @@ public function setUp()
1717
$this->objectManager = new ObjectManager($this);
1818
}
1919
/**
20-
* @param bool $isSecure
2120
* @param string $uri
2221
* @param string|null $vary
2322
* @return \Magento\Framework\App\Request\Http
2423
*/
25-
protected function getRequestMock($isSecure, $uri, $vary = null)
24+
protected function getRequestMock($uri, $vary = null)
2625
{
2726
$requestMock = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false);
2827
$requestMock->expects($this->once())
29-
->method('isSecure')
30-
->willReturn($isSecure);
31-
$requestMock->expects($this->once())
32-
->method('getRequestUri')
28+
->method('getUriString')
3329
->willReturn($uri);
3430
$requestMock->expects($this->once())
3531
->method('get')
@@ -51,16 +47,15 @@ protected function getContextMock($getVeryStringCalledTimes, $vary)
5147
return $contextMock;
5248
}
5349
/**
54-
* @param bool $isSecure
5550
* @param string $uri
5651
* @param string|null $varyStringCookie
5752
* @param string|null $varyStringContext
5853
* @param string $expected
59-
* @dataProvider dataProvider
54+
* @dataProvider getValueDataProvider
6055
*/
61-
public function testGetValue($isSecure, $uri, $varyStringCookie, $varyStringContext, $expected)
56+
public function testGetValue($uri, $varyStringCookie, $varyStringContext, $expected)
6257
{
63-
$request = $this->getRequestMock($isSecure, $uri, $varyStringCookie);
58+
$request = $this->getRequestMock($uri, $varyStringCookie);
6459
$context = $this->getContextMock($varyStringCookie ? 0 : 1, $varyStringContext);
6560
$model = $this->objectManager->getObject(
6661
'\Magento\Framework\App\PageCache\Identifier',
@@ -74,17 +69,16 @@ public function testGetValue($isSecure, $uri, $varyStringCookie, $varyStringCont
7469
/**
7570
* @return array
7671
*/
77-
public function dataProvider()
72+
public function getValueDataProvider()
7873
{
79-
$uri = 'index.php/customer';
80-
$isSecure = 0;
74+
$uri = 'http://domain.com/customer';
8175
$vary = 1;
82-
$data = [$isSecure, $uri, $vary];
76+
$data = [$uri, $vary];
8377
ksort($data);
8478
$expected = md5(serialize($data));
8579
return [
86-
[$isSecure, $uri, $vary, null, $expected],
87-
[$isSecure, $uri, null, $vary, $expected]
80+
[$uri, $vary, null, $expected],
81+
[$uri, null, $vary, $expected]
8882
];
8983
}
9084
}

0 commit comments

Comments
 (0)