5
5
*/
6
6
namespace Magento \PageCache \Test \Unit \Model \Cache ;
7
7
8
+ use \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
9
+ use \Magento \PageCache \Model \Cache \Server ;
8
10
use \Zend \Uri \UriFactory ;
9
11
10
12
class ServerTest extends \PHPUnit_Framework_TestCase
11
13
{
12
- /** @var \Magento\PageCache\Model\Cache\ Server */
14
+ /** @var Server */
13
15
protected $ model ;
14
16
15
17
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\DeploymentConfig */
@@ -30,7 +32,7 @@ public function setUp()
30
32
->disableOriginalConstructor ()
31
33
->getMock ();
32
34
33
- $ objectManager = new \ Magento \ Framework \ TestFramework \ Unit \ Helper \ ObjectManager ($ this );
35
+ $ objectManager = new ObjectManager ($ this );
34
36
$ this ->model = $ objectManager ->getObject (
35
37
'Magento\PageCache\Model\Cache\Server ' ,
36
38
[
@@ -56,12 +58,9 @@ public function testGetUris(
56
58
$ url ,
57
59
$ hostConfig = null
58
60
) {
59
- $ this ->configMock ->expects ($ this ->once ())
60
- ->method ('get ' )
61
- ->willReturn ($ hostConfig );
62
- $ this ->requestMock ->expects ($ this ->exactly ($ getHttpHostCallCtr ))
63
- ->method ('getHttpHost ' )
64
- ->willReturn ($ httpHost );
61
+ $ this ->configMock ->expects ($ this ->once ())->method ('get ' )->willReturn ($ hostConfig );
62
+ $ this ->requestMock ->expects ($ this ->exactly ($ getHttpHostCallCtr ))->method ('getHttpHost ' )->willReturn ($ httpHost );
63
+
65
64
$ this ->urlBuilderMock ->expects ($ this ->exactly ($ getUrlCallCtr ))
66
65
->method ('getUrl ' )
67
66
->with ('* ' , ['_nosid ' => true ])
@@ -70,30 +69,32 @@ public function testGetUris(
70
69
$ uris = [];
71
70
if (null === $ hostConfig ) {
72
71
if (!empty ($ httpHost )) {
73
- $ uris [] = UriFactory::factory ('' )->setHost ($ httpHost )
74
- ->setPort (\Magento \PageCache \Model \Cache \Server::DEFAULT_PORT )
75
- ->setScheme ('http ' );
72
+ $ uris [] = UriFactory::factory ('' )->setHost ($ httpHost )->setPort (Server::DEFAULT_PORT );
76
73
}
77
74
if (!empty ($ url )) {
78
75
$ uris [] = UriFactory::factory ($ url );
79
76
}
80
77
} else {
81
78
foreach ($ hostConfig as $ host ) {
82
- $ port = isset ($ host ['port ' ]) ? $ host ['port ' ] : \Magento \PageCache \Model \Cache \Server::DEFAULT_PORT ;
83
- $ uris [] = UriFactory::factory ('' )->setHost ($ host ['host ' ])
84
- ->setPort ($ port )
85
- ->setScheme ('http ' );
79
+ $ port = isset ($ host ['port ' ]) ? $ host ['port ' ] : Server::DEFAULT_PORT ;
80
+ $ uris [] = UriFactory::factory ('' )->setHost ($ host ['host ' ])->setPort ($ port );
86
81
}
87
82
}
88
83
84
+ foreach ($ uris as $ key => $ value ) {
85
+ $ uris [$ key ]->setScheme ('http ' )
86
+ ->setPath ('/ ' )
87
+ ->setQuery (null );
88
+ }
89
+
89
90
$ this ->assertEquals ($ uris , $ this ->model ->getUris ());
90
91
}
91
92
92
93
public function getUrisDataProvider ()
93
94
{
94
95
return [
95
- 'http host ' => [1 , '127.0.0.1 ' , 0 , '' , ],
96
- 'url ' => [1 , '' , 1 , 'http://host ' , ],
96
+ 'http host ' => [2 , '127.0.0.1 ' , 0 , '' ],
97
+ 'url ' => [1 , '' , 1 , 'http://host ' ],
97
98
'config ' => [
98
99
0 ,
99
100
'' ,
0 commit comments