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()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ListNormalizerTest::setUp()
- 11.x 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 46
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.
$this->typedData = $this->createMock('Drupal\\Core\\TypedData\\TypedDataInterface');
$typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
$typed_data_manager->expects($this->any())
->method('getPropertyInstance')
->will($this->returnValue($this->typedData));
// Set up a mock container as ItemList() will call for the 'typed_data_manager'
// service.
$container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')
->setMethods([
'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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.