-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MAGETWO-59376' of https://github.com/magento-falcons/ma…
…gento2ce into MAGETWO-59376
- Loading branch information
Showing
2 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\ObjectManager\Test\Unit\Config; | ||
|
||
use Magento\Framework\ObjectManager\Config\Compiled as CompiledConfig; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; | ||
|
||
class CompiledTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var ObjectManagerHelper | ||
*/ | ||
private $objectManagerHelper; | ||
|
||
protected function setUp() | ||
{ | ||
$this->objectManagerHelper = new ObjectManagerHelper($this); | ||
} | ||
|
||
/** | ||
* @param array $initialData | ||
* @param array $configuration | ||
* @param array $expectedArguments | ||
* @param array $expectedVirtualTypes | ||
* @param array $expectedPreferences | ||
* | ||
* @dataProvider extendDataProvider | ||
*/ | ||
public function testExtend( | ||
array $initialData, | ||
array $configuration, | ||
array $expectedArguments, | ||
array $expectedVirtualTypes, | ||
array $expectedPreferences | ||
) { | ||
/** @var CompiledConfig $compiledConfig */ | ||
$compiledConfig = $this->objectManagerHelper->getObject(CompiledConfig::class, ['data' => $initialData]); | ||
$compiledConfig->extend($configuration); | ||
|
||
foreach ($expectedArguments as $type => $arguments) { | ||
$this->assertEquals($arguments, $compiledConfig->getArguments($type)); | ||
} | ||
|
||
$this->assertEquals($expectedVirtualTypes, $compiledConfig->getVirtualTypes()); | ||
$this->assertEquals($expectedPreferences, $compiledConfig->getPreferences()); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function extendDataProvider() | ||
{ | ||
return [ | ||
[ | ||
'initialData' => [ | ||
'arguments' => [ | ||
'type1' => serialize(['argument1_1' => 'argumentValue1_1', 'argument1_2' => 'argumentValue1_2']) | ||
], | ||
'instanceTypes' => [ | ||
'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'instanceTypeValue2' | ||
], | ||
'preferences' => ['preference1' => 'preferenceValue1', 'preference2' => 'preferenceValue2'] | ||
], | ||
'configuration' => [ | ||
'arguments' => [ | ||
'type1' => serialize(['argument1_1' => 'newArgumentValue1_1']), | ||
'type2' => serialize(['argument2_1' => 'newArgumentValue2_1']) | ||
], | ||
'instanceTypes' => [ | ||
'instanceType2' => 'newInstanceTypeValue2', 'instanceType3' => 'newInstanceTypeValue3' | ||
], | ||
'preferences' => ['preference1' => 'newPreferenceValue1'] | ||
], | ||
'expectedArguments' => [ | ||
'type1' => ['argument1_1' => 'newArgumentValue1_1'], | ||
'type2' => ['argument2_1' => 'newArgumentValue2_1'] | ||
], | ||
'expectedVirtualTypes' => [ | ||
'instanceType1' => 'instanceTypeValue1', 'instanceType2' => 'newInstanceTypeValue2', | ||
'instanceType3' => 'newInstanceTypeValue3' | ||
], | ||
'expectedPreferences' => [ | ||
'preference1' => 'newPreferenceValue1', 'preference2' => 'preferenceValue2' | ||
] | ||
] | ||
]; | ||
} | ||
} |