Skip to content

Commit 0dfc0b3

Browse files
authored
Merge pull request #401 from drpayyne/tests-09
Added test coverage for PluginInspection
2 parents 69b4a2e + 594fdf7 commit 0dfc0b3

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Plugin\Block;
8+
9+
class Topmenu
10+
{
11+
public function aroundSomeMethod(\Magento\Theme\Block\Html\Topmenu $subject, \Magento\Theme\Block\Html\Topmenu $proceed)
12+
{
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Plugin\Block;
8+
9+
class Topmenu
10+
{
11+
public function aroundSomeMethod(\Magento\Catalog\Block\Navigation $subject, callable $proceed)
12+
{
13+
}
14+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.inspections.php;
7+
8+
import com.jetbrains.php.PhpBundle;
9+
10+
public class PluginInspectionTest extends InspectionPhpFixtureTestCase {
11+
12+
@Override
13+
public void setUp() throws Exception {
14+
super.setUp();
15+
myFixture.enableInspections(PluginInspection.class);
16+
}
17+
18+
@Override
19+
protected boolean isWriteActionRequired() {
20+
return false;
21+
}
22+
23+
/**
24+
* Inspection highlights error in parameter type.
25+
*/
26+
public void testWithWrongParameterType() {
27+
myFixture.configureByFile(getFixturePath("Plugin.php"));
28+
29+
final String wrongParameterError = PhpBundle.message(
30+
"inspection.wrong_param_type",
31+
"\\Magento\\Catalog\\Block\\Navigation",
32+
"\\Magento\\Theme\\Block\\Html\\Topmenu"
33+
);
34+
35+
assertHasHighlighting(wrongParameterError);
36+
}
37+
38+
/**
39+
* Inspection highlights error in callable parameter type.
40+
*/
41+
public void testWithWrongCallableType() {
42+
myFixture.configureByFile(getFixturePath("Plugin.php"));
43+
44+
final String wrongParameterError = PhpBundle.message(
45+
"inspection.wrong_param_type",
46+
"\\Magento\\Theme\\Block\\Html\\Topmenu",
47+
"callable"
48+
);
49+
50+
assertHasHighlighting(wrongParameterError);
51+
}
52+
}

0 commit comments

Comments
 (0)