protected function ListNormalizerTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ListNormalizerTest::setUp()
Overrides UnitTestCase::setUp
File
- core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ ListNormalizerTest.php, line 42 - Contains \Drupal\Tests\serialization\Unit\Normalizer\ListNormalizerTest.
Class
- ListNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\ListNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
protected function setUp() {
// Mock the TypedDataManager to return a TypedDataInterface mock.
$typed_data = $this
->getMock('Drupal\\Core\\TypedData\\TypedDataInterface');
$typed_data_manager = $this
->getMockBuilder('Drupal\\Core\\TypedData\\TypedDataManager')
->disableOriginalConstructor()
->setMethods(array(
'getPropertyInstance',
))
->getMock();
$typed_data_manager
->expects($this
->any())
->method('getPropertyInstance')
->will($this
->returnValue($typed_data));
// Set up a mock container as ItemList() will call for the 'typed_data_manager'
// service.
$container = $this
->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')
->setMethods(array(
'get',
))
->getMock();
$container
->expects($this
->any())
->method('get')
->with($this
->equalTo('typed_data_manager'))
->will($this
->returnValue($typed_data_manager));
\Drupal::setContainer($container);
$this->normalizer = new ListNormalizer();
$this->list = new ItemList(new DataDefinition());
$this->list
->setValue($this->expectedListValues);
}