Skip to content

Commit d96d03c

Browse files
authored
Merge pull request #360 from drpayyne/tests-322
Added tests for PluginTargetLineMarkerProvider
2 parents 09b3683 + f0bd182 commit d96d03c

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 beforeSomeMethod(\Magento\Theme\Block\Html\Topmenu $subject)
12+
{
13+
}
14+
15+
public function afterSomeMethod(\Magento\Theme\Block\Html\Topmenu $subject, $result)
16+
{
17+
}
18+
19+
public function aroundSomeMethod(\Magento\Theme\Block\Html\Topmenu $subject, callable $proceed)
20+
{
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;
8+
9+
class MviewState
10+
{
11+
public function beforeSetStatus(\Magento\Framework\Mview\View\StateInterface $subject)
12+
{
13+
}
14+
15+
public function afterSetStatus(\Magento\Framework\Mview\View\StateInterface $subject, $result)
16+
{
17+
}
18+
19+
public function aroundSetStatus(\Magento\Framework\Mview\View\StateInterface $subject, callable $proceed)
20+
{
21+
}
22+
}
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\Model;
8+
9+
class ClassNotConfiguredInDiXml
10+
{
11+
public function someMethod()
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\Framework\Mview\View;
8+
9+
interface StateInterface
10+
{
11+
public function setStatus($status)
12+
{
13+
}
14+
}

testData/project/magento2/vendor/magento/module-catalog/etc/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
<type name="Magento\Theme\Block\Html\Topmenu">
44
<plugin name="catalogTopmenu" type="Magento\Catalog\Plugin\Block\Topmenu" />
55
</type>
6+
<type name="Magento\Framework\Mview\View\StateInterface">
7+
<plugin name="setStatusForMview"
8+
type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState"/>
9+
</type>
610
</config>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.linemarker.php;
7+
8+
@SuppressWarnings("PMD.JUnitTestContainsTooManyAsserts")
9+
public class PluginTargetLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase {
10+
11+
/**
12+
* Tests linemarkers in a class which plugs in to a class and its method.
13+
*/
14+
public void testPluginToClassShouldHaveLinemarker() {
15+
myFixture.configureByFile(this.getFixturePath("Topmenu.php"));
16+
17+
assertHasLinemarkerWithTooltipAndIcon("Navigate to target method", "/nodes/method.svg");
18+
assertHasLinemarkerWithTooltipAndIcon("Navigate to target class", "/nodes/class.svg");
19+
}
20+
21+
/**
22+
* Tests linemarkers in a class which plugs in to an interface and its method.
23+
*/
24+
public void testPluginToInterfaceShouldHaveLinemarker() {
25+
myFixture.configureByFile(this.getFixturePath("MviewState.php"));
26+
27+
assertHasLinemarkerWithTooltipAndIcon("Navigate to target method", "/nodes/method.svg");
28+
assertHasLinemarkerWithTooltipAndIcon("Navigate to target class", "/nodes/class.svg");
29+
}
30+
31+
/**
32+
* Tests linemarkers in a regular class which does not plug in to any class or interface.
33+
*/
34+
public void testRegularClassShouldNotHaveLinemarker() {
35+
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInDiXml.php"));
36+
37+
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to target method", "/nodes/method.svg");
38+
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to target class", "/nodes/class.svg");
39+
}
40+
}

0 commit comments

Comments
 (0)