11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2015 Adobe
4+ * All Rights Reserved .
55 */
66declare (strict_types=1 );
77
1010use Magento \Framework \App \Cache \Manager ;
1111use Magento \Framework \App \Interception \Cache \CompiledConfig ;
1212use Magento \Framework \Interception \Config \Config ;
13+ use Magento \Framework \Interception \ObjectManager \ConfigInterface ;
1314use Magento \Framework \ObjectManager \InterceptableValidator ;
1415use Magento \Setup \Module \Di \Code \Generator \InterceptionConfigurationBuilder ;
1516use Magento \Setup \Module \Di \Code \Generator \PluginList ;
1617use Magento \Setup \Module \Di \Code \Reader \Type ;
1718use PHPUnit \Framework \MockObject \MockObject ;
1819use PHPUnit \Framework \TestCase ;
19- use stdClass ;
2020
2121class InterceptionConfigurationBuilderTest extends TestCase
2222{
@@ -50,25 +50,30 @@ class InterceptionConfigurationBuilderTest extends TestCase
5050 */
5151 private $ interceptableValidator ;
5252
53+ /**
54+ * @var MockObject
55+ */
56+ private $ omConfig ;
57+
5358 protected function setUp (): void
5459 {
55- $ this ->interceptionConfig =
56- $ this ->createPartialMock (Config::class, ['hasPlugins ' ]);
60+ $ this ->interceptionConfig = $ this ->createPartialMock (Config::class, ['hasPlugins ' ]);
5761 $ this ->pluginList = $ this ->createPartialMock (
5862 PluginList::class,
5963 ['setInterceptedClasses ' , 'setScopePriorityScheme ' , 'getPluginsConfig ' ]
6064 );
6165 $ this ->cacheManager = $ this ->createMock (Manager::class);
62- $ this ->interceptableValidator =
63- $ this ->createMock (InterceptableValidator ::class);
66+ $ this ->interceptableValidator = $ this -> createMock (InterceptableValidator::class);
67+ $ this -> omConfig = $ this ->createMock (ConfigInterface ::class);
6468
6569 $ this ->typeReader = $ this ->createPartialMock (Type::class, ['isConcrete ' ]);
6670 $ this ->model = new InterceptionConfigurationBuilder (
6771 $ this ->interceptionConfig ,
6872 $ this ->pluginList ,
6973 $ this ->typeReader ,
7074 $ this ->cacheManager ,
71- $ this ->interceptableValidator
75+ $ this ->interceptableValidator ,
76+ $ this ->omConfig
7277 );
7378 }
7479
@@ -106,6 +111,13 @@ public function testGetInterceptionConfiguration($plugins)
106111 ->method ('getPluginsConfig ' )
107112 ->willReturn (['instance ' => $ plugins ]);
108113
114+ $ this ->omConfig ->expects ($ this ->any ())
115+ ->method ('getOriginalInstanceType ' )
116+ ->willReturnMap ([
117+ ['stdClass ' , 'stdClass ' ],
118+ ['virtualTypeClass ' , 'stdClass ' ],
119+ ]);
120+
109121 $ this ->model ->addAreaCode ('areaCode ' );
110122 $ this ->model ->getInterceptionConfiguration ($ definedClasses );
111123 }
@@ -115,11 +127,15 @@ public function testGetInterceptionConfiguration($plugins)
115127 */
116128 public static function getInterceptionConfigurationDataProvider ()
117129 {
118- $ someInstance = new stdClass ();
119130 return [
120131 [null ],
121- [['plugin ' => ['instance ' => $ someInstance ]]],
122- [['plugin ' => ['instance ' => $ someInstance ], 'plugin2 ' => ['instance ' => $ someInstance ]]]
132+ [['plugin ' => ['instance ' => 'stdClass ' ]]],
133+ [[
134+ 'plugin ' => ['instance ' => 'stdClass ' ],
135+ 'plugin1 ' => ['instance ' => 'stdClass ' ],
136+ 'plugin2 ' => ['instance ' => 'virtualTypeClass ' ]
137+ ]],
138+ [['plugin ' => ['instance ' => 'virtualTypeClass ' ]]],
123139 ];
124140 }
125141}
0 commit comments