buildExampleTypedDataWithProperties example

->addConstraint('NotNull')
    );
    $violations = $this->recursiveValidator->validate($typed_data);
    $this->assertCount(2, $violations);
  }

  /** * @covers ::validate */
  public function testPropertiesValidateWithMultipleLevels() {

    $typed_data = $this->buildExampleTypedDataWithProperties();

    $violations = $this->recursiveValidator->validate($typed_data);
    $this->assertCount(6, $violations);

    $this->assertEquals('violation: 3', $violations->get(0)->getMessage());
    $this->assertEquals('violation: value1', $violations->get(1)->getMessage());
    $this->assertEquals('violation: value2', $violations->get(2)->getMessage());
    $this->assertEquals('violation: 2', $violations->get(3)->getMessage());
    $this->assertEquals('violation: subvalue1', $violations->get(4)->getMessage());
    $this->assertEquals('violation: subvalue2', $violations->get(5)->getMessage());

    
1 => 'value6',
        'key7' => 'value7',
      ],
    ];
    $this->assertSame($expect_value$data);
  }

  /** * Tests whether map data with properties can be normalized. */
  public function testMapWithPropertiesNormalize() {
    $typed_data = $this->buildExampleTypedDataWithProperties();
    $data = $this->serializer->normalize($typed_data, 'json');
    $expect_value = [
      'key1' => 'value1',
      'key2' => 'value2',
      'key3' => 3,
      'key4' => [
        0 => TRUE,
        1 => 'value6',
        'key7' => 'value7',
      ],
    ];
    
Home | Imprint | This part of the site doesn't use cookies.