@@ -59,6 +59,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
59
59
*/
60
60
protected $ title ;
61
61
62
+ /**
63
+ * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
64
+ */
65
+ protected $ areaResolverMock ;
66
+
62
67
public function setUp ()
63
68
{
64
69
$ this ->assetRepo = $ this ->getMock ('Magento\Framework\View\Asset\Repository ' , [], [], '' , false );
@@ -84,6 +89,11 @@ public function setUp()
84
89
'localeResolver ' => $ locale ,
85
90
]
86
91
);
92
+
93
+ $ this ->areaResolverMock = $ this ->getMock ('Magento\Framework\App\State ' , [], [], '' , false );
94
+ $ areaResolverReflection = (new \ReflectionClass (get_class ($ this ->model )))->getProperty ('areaResolver ' );
95
+ $ areaResolverReflection ->setAccessible (true );
96
+ $ areaResolverReflection ->setValue ($ this ->model , $ this ->areaResolverMock );
87
97
}
88
98
89
99
public function testSetBuilder ()
@@ -202,13 +212,15 @@ public function testKeywordsEmpty()
202
212
203
213
public function testRobots ()
204
214
{
215
+ $ this ->areaResolverMock ->expects ($ this ->once ())->method ('getAreaCode ' )->willReturn ('frontend ' );
205
216
$ robots = 'test_robots ' ;
206
217
$ this ->model ->setRobots ($ robots );
207
218
$ this ->assertEquals ($ robots , $ this ->model ->getRobots ());
208
219
}
209
220
210
221
public function testRobotsEmpty ()
211
222
{
223
+ $ this ->areaResolverMock ->expects ($ this ->once ())->method ('getAreaCode ' )->willReturn ('frontend ' );
212
224
$ expectedData = 'default_robots ' ;
213
225
$ this ->scopeConfig ->expects ($ this ->once ())->method ('getValue ' )->with (
214
226
'design/search_engine_robots/default_robots ' ,
@@ -218,6 +230,14 @@ public function testRobotsEmpty()
218
230
$ this ->assertEquals ($ expectedData , $ this ->model ->getRobots ());
219
231
}
220
232
233
+ public function testRobotsAdminhtml ()
234
+ {
235
+ $ this ->areaResolverMock ->expects ($ this ->once ())->method ('getAreaCode ' )->willReturn ('adminhtml ' );
236
+ $ robots = 'test_robots ' ;
237
+ $ this ->model ->setRobots ($ robots );
238
+ $ this ->assertEquals ('NOINDEX,NOFOLLOW ' , $ this ->model ->getRobots ());
239
+ }
240
+
221
241
public function testGetAssetCollection ()
222
242
{
223
243
$ this ->assertInstanceOf ('Magento\Framework\View\Asset\GroupedCollection ' , $ this ->model ->getAssetCollection ());
0 commit comments