Skip to content

Commit 8eee7f9

Browse files
author
Yuriy Tkachenko
committed
Add integration test
1 parent 85e6dee commit 8eee7f9

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

dev/tests/integration/testsuite/Magento/Framework/ObjectManager/ObjectManagerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
*/
66
namespace Magento\Framework\ObjectManager;
77

8+
use Magento\Framework\Exception\RuntimeException;
9+
810
class ObjectManagerTest extends \PHPUnit\Framework\TestCase
911
{
12+
/**#@+
13+
* Test class with throwable error
14+
*/
15+
const TEST_CLASS_WITH_THROWABLE = \Magento\Framework\ObjectManager\TestAsset\ConstructorWithThrowable::class;
16+
1017
/**#@+
1118
* Test classes for basic instantiation
1219
*/
@@ -138,4 +145,17 @@ public function testNewInstance($actualClassName, array $properties = [], $expec
138145
}
139146
}
140147
}
148+
149+
/**
150+
* Test create instance with throwable error
151+
*/
152+
public function testNewInstanceWithThrowableError()
153+
{
154+
try {
155+
$testObject = self::$_objectManager->create(self::TEST_CLASS_WITH_THROWABLE);
156+
$this->fail('No instance for class with throwable error should be created');
157+
} catch (\Throwable $e) {
158+
$this->assertInstanceOf(RuntimeException::class, $e);
159+
}
160+
}
141161
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @author Atwix Team
4+
* @copyright Copyright (c) 2018 Atwix (https://www.atwix.com/)
5+
*/
6+
7+
8+
namespace Magento\Framework\ObjectManager\TestAsset;
9+
10+
11+
class ConstructorWithThrowable extends \Magento\Framework\ObjectManager\TestAsset\ConstructorOneArgument
12+
{
13+
public function __construct(Basic $one)
14+
{
15+
// Call parent constructor without parameters to generate TypeError
16+
parent::__construct();
17+
}
18+
}

0 commit comments

Comments
 (0)