TypedDataNormalizerTest.php in Drupal 9
File
core/modules/serialization/tests/src/Unit/Normalizer/TypedDataNormalizerTest.php
View source
<?php
namespace Drupal\Tests\serialization\Unit\Normalizer;
use Drupal\Tests\UnitTestCase;
use Drupal\serialization\Normalizer\TypedDataNormalizer;
class TypedDataNormalizerTest extends UnitTestCase {
protected $normalizer;
protected $typedData;
protected function setUp() : void {
$this->normalizer = new TypedDataNormalizer();
$this->typedData = $this
->createMock('Drupal\\Core\\TypedData\\TypedDataInterface');
}
public function testSupportsNormalization() {
$this
->assertTrue($this->normalizer
->supportsNormalization($this->typedData));
$this
->assertFalse($this->normalizer
->supportsNormalization(new \stdClass()));
}
public function testNormalize() {
$this->typedData
->expects($this
->once())
->method('getValue')
->will($this
->returnValue('test'));
$this
->assertEquals('test', $this->normalizer
->normalize($this->typedData));
}
}