Skip to content

Commit 6448147

Browse files
unit test coverage
1 parent f619400 commit 6448147

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Framework\ObjectManager\Test\Unit\Factory;
99

10+
use Magento\Framework\Exception\RuntimeException;
1011
use Magento\Framework\ObjectManager\ConfigInterface;
1112
use Magento\Framework\ObjectManager\DefinitionInterface;
1213
use Magento\Framework\ObjectManager\Factory\Compiled;
@@ -19,6 +20,8 @@
1920
use PHPUnit\Framework\TestCase;
2021

2122
/**
23+
* Test for \Magento\Framework\ObjectManager\Factory\Compiled.
24+
*
2225
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2326
*/
2427
class CompiledTest extends TestCase
@@ -116,6 +119,27 @@ public function testCreateSimple()
116119
$this->assertNull($result->getNullValue());
117120
}
118121

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+
119143
/**
120144
* Test create simple configured arguments
121145
*/

0 commit comments

Comments
 (0)