class NullNormalizerTest

Same name and namespace in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/NullNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\NullNormalizerTest
  2. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/NullNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\NullNormalizerTest
  3. 10 core/modules/serialization/tests/src/Unit/Normalizer/NullNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\NullNormalizerTest

@coversDefaultClass \Drupal\serialization\Normalizer\NullNormalizer
@group serialization

Hierarchy

Expanded class hierarchy of NullNormalizerTest

File

core/modules/serialization/tests/src/Unit/Normalizer/NullNormalizerTest.php, line 16

Namespace

Drupal\Tests\serialization\Unit\Normalizer
View source
class NullNormalizerTest extends UnitTestCase {
  use JsonSchemaTestTrait;
  
  /**
   * The NullNormalizer instance.
   *
   * @var \Drupal\serialization\Normalizer\NullNormalizer
   */
  protected $normalizer;
  
  /**
   * The interface to use in testing.
   *
   * @var string
   */
  protected $interface = 'Drupal\\Core\\TypedData\\TypedDataInterface';
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->normalizer = new NullNormalizer($this->interface);
  }
  
  /**
   * @covers ::__construct
   * @covers ::supportsNormalization
   */
  public function testSupportsNormalization() : void {
    $mock = $this->createMock('Drupal\\Core\\TypedData\\TypedDataInterface');
    $this->assertTrue($this->normalizer
      ->supportsNormalization($mock));
    // Also test that an object not implementing TypedDataInterface fails.
    $this->assertFalse($this->normalizer
      ->supportsNormalization(new \stdClass()));
  }
  
  /**
   * @covers ::normalize
   */
  public function testNormalize() : void {
    $mock = $this->createMock('Drupal\\Core\\TypedData\\TypedDataInterface');
    $this->assertNull($this->normalizer
      ->normalize($mock));
  }
  
  /**
   * {@inheritdoc}
   */
  public static function jsonSchemaDataProvider() : array {
    return [
      'null' => [
        TypedDataInterface::class,
      ],
    ];
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ExpectDeprecationTrait::expectDeprecation public function Adds an expected deprecation.
ExpectDeprecationTrait::setUpErrorHandler public function Sets up the test error handler.
ExpectDeprecationTrait::tearDownErrorHandler public function Tears down the test error handler.
JsonSchemaTestTrait::doCheckSchemaAgainstMetaSchema protected function Check a schema is valid against the meta-schema.
JsonSchemaTestTrait::doProphesize public function Method to make prophecy public for use in data provider closures.
JsonSchemaTestTrait::doTestJsonSchemaIsValid public function Validate the normalizer's JSON schema.
JsonSchemaTestTrait::getJsonSchemaTestNormalizationFormat protected function Format that should be used when performing test normalizations. 1
JsonSchemaTestTrait::getNormalizationForValue protected function Get the normalization for a value.
JsonSchemaTestTrait::getNormalizer protected function Helper method to retrieve the normalizer. 1
JsonSchemaTestTrait::getValidator protected function Get the JSON Schema Validator. 1
JsonSchemaTestTrait::supportedTypesDataProvider public static function
JsonSchemaTestTrait::testNormalizedValuesAgainstJsonSchema public function Test normalized values against the JSON schema.
JsonSchemaTestTrait::testSupportedTypesSchemaIsValid public function Test that a valid schema is returned for the explicitly supported types.
NullNormalizerTest::$interface protected property The interface to use in testing.
NullNormalizerTest::$normalizer protected property The NullNormalizer instance.
NullNormalizerTest::jsonSchemaDataProvider public static function Data provider for ::testNormalizedValuesAgainstJsonSchema. Overrides JsonSchemaTestTrait::jsonSchemaDataProvider
NullNormalizerTest::setUp protected function Overrides UnitTestCase::setUp
NullNormalizerTest::testNormalize public function @covers ::normalize[[api-linebreak]]
NullNormalizerTest::testSupportsNormalization public function @covers ::__construct[[api-linebreak]]
@covers ::supportsNormalization[[api-linebreak]]
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
UnitTestCase::$root protected property The app root.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setDebugDumpHandler public static function Registers the dumper CLI handler when the DebugDump extension is enabled.
UnitTestCase::setupMockIterator protected function Set up a traversable class mock to return specific items when iterated.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.