9
9
10
10
use Magento \Framework \App \ProductMetadataInterface ;
11
11
use Magento \Framework \App \ResponseInterface ;
12
+ use Magento \Framework \Controller \Result \Raw ;
13
+ use Magento \Framework \Controller \Result \RawFactory ;
12
14
use Magento \Version \Controller \Index \Index as VersionIndex ;
15
+ use PHPUnit \Framework \MockObject \MockObject ;
13
16
use PHPUnit \Framework \TestCase ;
14
17
15
18
class IndexTest extends TestCase
16
19
{
17
- /**
18
- * @var VersionIndex
19
- */
20
+ /** @var VersionIndex */
20
21
private $ versionController ;
21
22
22
- /**
23
- * @var ProductMetadataInterface
24
- */
23
+ /** @var MockObject|ProductMetadataInterface */
25
24
private $ productMetadataMock ;
26
25
27
- /**
28
- * @var ResponseInterface
29
- */
30
- private $ responseMock ;
26
+ /** @var MockObject|RawFactory */
27
+ private $ rawResponseFactoryMock ;
28
+
29
+ /** @var MockObject|Raw */
30
+ private $ rawResponseMock ;
31
31
32
32
/**
33
33
* Prepare test preconditions
@@ -39,12 +39,11 @@ protected function setUp()
39
39
->setMethods (['getName ' , 'getEdition ' , 'getVersion ' ])
40
40
->getMock ();
41
41
42
- $ this ->responseMock = $ this ->getMockBuilder (ResponseInterface::class)
43
- ->disableOriginalConstructor ()
44
- ->setMethods (['setBody ' , 'sendResponse ' ])
45
- ->getMock ();
42
+ $ this ->rawResponseFactoryMock = $ this ->createPartialMock (RawFactory::class, ['create ' ]);
43
+ $ this ->rawResponseMock = $ this ->createPartialMock (Raw::class, ['setContents ' ]);
44
+ $ this ->rawResponseFactoryMock ->method ('create ' )->willReturn ($ this ->rawResponseMock );
46
45
47
- $ this ->versionController = new VersionIndex ($ this ->responseMock , $ this ->productMetadataMock );
46
+ $ this ->versionController = new VersionIndex ($ this ->rawResponseFactoryMock , $ this ->productMetadataMock );
48
47
}
49
48
50
49
/**
@@ -56,10 +55,10 @@ public function testGitBasedInstallationDoesNotReturnVersion(): void
56
55
->method ('getVersion ' )
57
56
->willReturn ('dev-2.3 ' );
58
57
59
- $ this ->responseMock ->expects ($ this ->never ())
60
- ->method ('setBody ' );
58
+ $ this ->rawResponseMock ->expects ($ this ->never ())
59
+ ->method ('setContents ' );
61
60
62
- $ this ->assertNull ( $ this -> versionController ->execute () );
61
+ $ this ->versionController ->execute ();
63
62
}
64
63
65
64
/**
@@ -71,7 +70,7 @@ public function testCommunityVersionDisplaysMajorMinorVersionAndEditionName(): v
71
70
$ this ->productMetadataMock ->expects ($ this ->any ())->method ('getEdition ' )->willReturn ('Community ' );
72
71
$ this ->productMetadataMock ->expects ($ this ->any ())->method ('getName ' )->willReturn ('Magento ' );
73
72
74
- $ this ->responseMock ->expects ($ this ->once ())->method ('setBody ' )
73
+ $ this ->rawResponseMock ->expects ($ this ->once ())->method ('setContents ' )
75
74
->with ('Magento/2.3 (Community) ' )
76
75
->will ($ this ->returnSelf ());
77
76
0 commit comments