7
7
8
8
namespace Magento \Version \Test \Unit \Controller \Index ;
9
9
10
- use Magento \Framework \App \Action \Context ;
11
10
use Magento \Framework \App \ProductMetadataInterface ;
12
11
use Magento \Framework \App \ResponseInterface ;
13
- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
14
12
use Magento \Version \Controller \Index \Index as VersionIndex ;
15
13
use PHPUnit \Framework \TestCase ;
16
14
@@ -19,12 +17,7 @@ class IndexTest extends TestCase
19
17
/**
20
18
* @var VersionIndex
21
19
*/
22
- private $ model ;
23
-
24
- /**
25
- * @var Context
26
- */
27
- private $ contextMock ;
20
+ private $ versionController ;
28
21
29
22
/**
30
23
* @var ProductMetadataInterface
@@ -41,10 +34,6 @@ class IndexTest extends TestCase
41
34
*/
42
35
protected function setUp ()
43
36
{
44
- $ this ->contextMock = $ this ->getMockBuilder (Context::class)
45
- ->disableOriginalConstructor ()
46
- ->getMock ();
47
-
48
37
$ this ->productMetadataMock = $ this ->getMockBuilder (ProductMetadataInterface::class)
49
38
->disableOriginalConstructor ()
50
39
->setMethods (['getName ' , 'getEdition ' , 'getVersion ' ])
@@ -55,19 +44,7 @@ protected function setUp()
55
44
->setMethods (['setBody ' , 'sendResponse ' ])
56
45
->getMock ();
57
46
58
- $ this ->contextMock ->expects ($ this ->any ())
59
- ->method ('getResponse ' )
60
- ->willReturn ($ this ->responseMock );
61
-
62
- $ objectManager = new ObjectManager ($ this );
63
-
64
- $ this ->model = $ objectManager ->getObject (
65
- VersionIndex::class,
66
- [
67
- 'context ' => $ this ->contextMock ,
68
- 'productMetadata ' => $ this ->productMetadataMock
69
- ]
70
- );
47
+ $ this ->versionController = new VersionIndex ($ this ->responseMock , $ this ->productMetadataMock );
71
48
}
72
49
73
50
/**
@@ -82,7 +59,7 @@ public function testGitBasedInstallationDoesNotReturnVersion(): void
82
59
$ this ->responseMock ->expects ($ this ->never ())
83
60
->method ('setBody ' );
84
61
85
- $ this ->assertNull ($ this ->model ->execute ());
62
+ $ this ->assertNull ($ this ->versionController ->execute ());
86
63
}
87
64
88
65
/**
@@ -98,6 +75,6 @@ public function testCommunityVersionDisplaysMajorMinorVersionAndEditionName(): v
98
75
->with ('Magento/2.3 (Community) ' )
99
76
->will ($ this ->returnSelf ());
100
77
101
- $ this ->model ->execute ();
78
+ $ this ->versionController ->execute ();
102
79
}
103
80
}
0 commit comments