function ListNormalizerTest::setUp
Same name in other branches
- 9 core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ListNormalizerTest::setUp()
- 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ListNormalizerTest::setUp()
- 10 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 51
Class
- ListNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\ListNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
protected function setUp() : void {
parent::setUp();
// Mock the TypedDataManager to return a TypedDataInterface mock.
$this->typedData = $this->createMock('Drupal\\Core\\TypedData\\TypedDataInterface');
$typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
$typed_data_manager->expects($this->any())
->method('getPropertyInstance')
->willReturn($this->typedData);
// Set up a mock container as ItemList() will call for the 'typed_data_manager'
// service.
$container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')
->onlyMethods([
'get',
])
->getMock();
$container->expects($this->any())
->method('get')
->with($this->equalTo('typed_data_manager'))
->willReturn($typed_data_manager);
\Drupal::setContainer($container);
$this->normalizer = new ListNormalizer();
$this->list = new ItemList(new DataDefinition());
$this->list
->setValue($this->expectedListValues);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.