protected function ListNormalizerTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 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);
}