Skip to content

Commit 2876cc5

Browse files
committed
MAGETWO-85755: Enable metrics validation and run benchmark in multithread mode for PAT
1 parent 8798ee6 commit 2876cc5

File tree

1 file changed

+68
-71
lines changed

1 file changed

+68
-71
lines changed
Lines changed: 68 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,91 @@
11
<?php
22
/**
3-
* Copyright © 2013-2018 Magento, Inc. All rights reserved.
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento\Framework\ObjectManager\Test\Unit\Config;
77

8-
use Magento\Framework\ObjectManager\Config\Compiled;
9-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager;
8+
use Magento\Framework\ObjectManager\Config\Compiled as CompiledConfig;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1010

1111
class CompiledTest extends \PHPUnit_Framework_TestCase
1212
{
1313
/**
14-
* @var ObjectManager
14+
* @var ObjectManagerHelper
1515
*/
16-
private $objectManager;
17-
18-
/**
19-
* @var \Magento\Framework\ObjectManager\Config\Compiled
20-
*/
21-
private $compiled;
16+
private $objectManagerHelper;
2217

2318
protected function setUp()
2419
{
25-
$this->objectManager = new ObjectManager($this);
20+
$this->objectManagerHelper = new ObjectManagerHelper($this);
21+
}
2622

27-
$initialData = [
28-
'arguments' => [
29-
'type1' => 'initial serialized configuration for type1',
30-
'class_with_no_arguments_serialized' => null,
31-
'class_with_arguments_serialized' => 'serialized arguments',
32-
'class_with_arguments_unserialized' => ['unserialized', 'arguments'],
33-
'class_with_no_arguments_unserialized' => [],
34-
],
35-
'instanceTypes' => [
36-
'instanceType1' => 'instanceTypeValue1',
37-
'instanceType2' => 'instanceTypeValue2'
38-
],
39-
'preferences' => [
40-
'preference1' => 'preferenceValue1',
41-
'preference2' => 'preferenceValue2'
42-
]
43-
];
23+
/**
24+
* @param array $initialData
25+
* @param array $configuration
26+
* @param array $expectedArguments
27+
* @param array $expectedVirtualTypes
28+
* @param array $expectedPreferences
29+
*
30+
* @dataProvider extendDataProvider
31+
*/
32+
public function testExtend(
33+
array $initialData,
34+
array $configuration,
35+
array $expectedArguments,
36+
array $expectedVirtualTypes,
37+
array $expectedPreferences
38+
) {
39+
/** @var CompiledConfig $compiledConfig */
40+
$compiledConfig = $this->objectManagerHelper->getObject(CompiledConfig::class, ['data' => $initialData]);
41+
$compiledConfig->extend($configuration);
4442

45-
$this->compiled = $this->objectManager->getObject(
46-
Compiled::class,
47-
[
48-
'data' => $initialData,
49-
]
50-
);
43+
foreach ($expectedArguments as $type => $arguments) {
44+
$this->assertEquals($arguments, $compiledConfig->getArguments($type));
45+
}
46+
47+
$this->assertEquals($expectedVirtualTypes, $compiledConfig->getVirtualTypes());
48+
$this->assertEquals($expectedPreferences, $compiledConfig->getPreferences());
5149
}
5250

53-
public function testExtend()
51+
/**
52+
* @return array
53+
*/
54+
public function extendDataProvider()
5455
{
55-
56-
$configuration = [
57-
'arguments' => [
58-
'type1' => 'serialized configuration for type1',
59-
'type2' => 'serialized configuration for type2'
60-
],
61-
'instanceTypes' => [
62-
'instanceType2' => 'newInstanceTypeValue2',
63-
'instanceType3' => 'newInstanceTypeValue3'
64-
],
65-
'preferences' => [
66-
'preference1' => 'newPreferenceValue1'
67-
]
68-
];
69-
$expectedArguments = [
70-
'type1' => [
71-
'argument1_1' => 'newArgumentValue1_1'
72-
],
73-
'type2' => [
74-
'argument2_1' => 'newArgumentValue2_1'
56+
return [
57+
[
58+
'initialData' => [
59+
'arguments' => [
60+
'type1' => serialize(['argument1_1' => 'argumentValue1_1', 'argument1_2' => 'argumentValue1_2'])
61+
],
62+
'instanceTypes' => [
63+
'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'instanceTypeValue2'
64+
],
65+
'preferences' => ['preference1' => 'preferenceValue1', 'preference2' => 'preferenceValue2']
66+
],
67+
'configuration' => [
68+
'arguments' => [
69+
'type1' => serialize(['argument1_1' => 'newArgumentValue1_1']),
70+
'type2' => serialize(['argument2_1' => 'newArgumentValue2_1'])
71+
],
72+
'instanceTypes' => [
73+
'instanceType2' => 'newInstanceTypeValue2', 'instanceType3' => 'newInstanceTypeValue3'
74+
],
75+
'preferences' => ['preference1' => 'newPreferenceValue1']
76+
],
77+
'expectedArguments' => [
78+
'type1' => ['argument1_1' => 'newArgumentValue1_1'],
79+
'type2' => ['argument2_1' => 'newArgumentValue2_1']
80+
],
81+
'expectedVirtualTypes' => [
82+
'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'newInstanceTypeValue2',
83+
'instanceType3' => 'newInstanceTypeValue3'
84+
],
85+
'expectedPreferences' => [
86+
'preference1' => 'newPreferenceValue1', 'preference2' => 'preferenceValue2'
87+
]
7588
]
7689
];
77-
$expectedVirtualTypes = [
78-
'instanceType1' => 'instanceTypeValue1',
79-
'instanceType2' => 'newInstanceTypeValue2',
80-
'instanceType3' => 'newInstanceTypeValue3'
81-
];
82-
$expectedPreferences = [
83-
'preference1' => 'newPreferenceValue1',
84-
'preference2' => 'preferenceValue2'
85-
];
86-
87-
$this->compiled->extend($configuration);
88-
foreach ($expectedArguments as $type => $arguments) {
89-
$this->assertEquals($arguments, $this->compiled->getArguments($type));
90-
}
91-
$this->assertEquals($expectedVirtualTypes, $this->compiled->getVirtualTypes());
92-
$this->assertEquals($expectedPreferences, $this->compiled->getPreferences());
9390
}
9491
}

0 commit comments

Comments
 (0)