File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \Framework \ObjectManager \Test \Unit \Factory ;
9
9
10
+ use Magento \Framework \Exception \RuntimeException ;
10
11
use Magento \Framework \ObjectManager \ConfigInterface ;
11
12
use Magento \Framework \ObjectManager \DefinitionInterface ;
12
13
use Magento \Framework \ObjectManager \Factory \Compiled ;
19
20
use PHPUnit \Framework \TestCase ;
20
21
21
22
/**
23
+ * Test for \Magento\Framework\ObjectManager\Factory\Compiled.
24
+ *
22
25
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23
26
*/
24
27
class CompiledTest extends TestCase
@@ -116,6 +119,27 @@ public function testCreateSimple()
116
119
$ this ->assertNull ($ result ->getNullValue ());
117
120
}
118
121
122
+ /**
123
+ * Create class with exception
124
+ *
125
+ * @return void
126
+ */
127
+ public function testCreateSimpleWithException (): void
128
+ {
129
+ $ requestedType = 'requestedType ' ;
130
+ $ className = SimpleClassTesting::class;
131
+
132
+ $ this ->config ->expects ($ this ->atLeastOnce ())
133
+ ->method ('getInstanceType ' )
134
+ ->willReturn ($ className );
135
+
136
+ $ this ->expectException (RuntimeException::class);
137
+ $ this ->expectExceptionMessage (
138
+ 'Type Error occurred when creating object: ' . $ className . ', Too few arguments to function ' . $ className
139
+ );
140
+ $ this ->factory ->create ($ requestedType , []);
141
+ }
142
+
119
143
/**
120
144
* Test create simple configured arguments
121
145
*/
You can’t perform that action at this time.
0 commit comments