InternalViolation example

/** * @coversDefaultClass \Drupal\Core\Field\InternalViolation * @group legacy */
class InternalViolationTest extends UnitTestCase {

  /** * @covers ::__get * @covers ::__set */
  public function testSetGetDynamicProperties() {
    $violation = new InternalViolation($this->prophesize(ConstraintViolationInterface::class)->reveal());
    $this->expectDeprecation('Setting dynamic properties on violations is deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3307919');
    $this->expectDeprecation('Accessing dynamic properties on violations is deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3307919');
    $violation->foo = 'bar';
    $this->assertSame('bar', $violation->foo);
  }

  /** * @covers ::__get * @covers ::__set */
  public function testSetGetArrayPropertyPath() {
    
return;
          }
        }
      }

      // Only set errors if the element is visible.       if (Element::isVisibleElement($element)) {
        $handles_multiple = $this->handlesMultipleValues();

        $violations_by_delta = $item_list_violations = [];
        foreach ($violations as $violation) {
          $violation = new InternalViolation($violation);
          // Separate violations by delta.           $property_path = explode('.', $violation->getPropertyPath());
          $delta = array_shift($property_path);
          if (is_numeric($delta)) {
            $violations_by_delta[$delta][] = $violation;
          }
          // Violations at the ItemList level are not associated to any delta.           else {
            $item_list_violations[] = $violation;
          }
          // @todo Remove BC layer https://www.drupal.org/i/3307859 on PHP 8.2.
Home | Imprint | This part of the site doesn't use cookies.