You are here

class FileMetadataExifTest in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 file_mdm_exif/tests/src/Kernel/FileMetadataExifTest.php \Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest

Tests that File Metadata EXIF plugin works properly.

@group File Metadata

Hierarchy

Expanded class hierarchy of FileMetadataExifTest

File

file_mdm_exif/tests/src/Kernel/FileMetadataExifTest.php, line 16

Namespace

Drupal\Tests\file_mdm_exif\Kernel
View source
class FileMetadataExifTest extends FileMetadataManagerTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'system',
    'simpletest',
    'file_mdm',
    'file_mdm_exif',
    'file_test',
    'image_effects',
  ];

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this
      ->installConfig([
      'file_mdm_exif',
    ]);
  }

  /**
   * Test EXIF plugin.
   */
  public function testExifPlugin() {

    // Prepare a copy of test files.
    file_unmanaged_copy(drupal_get_path('module', 'simpletest') . '/files/image-test.jpg', 'public://', FILE_EXISTS_REPLACE);
    file_unmanaged_copy(drupal_get_path('module', 'simpletest') . '/files/image-test.png', 'public://', FILE_EXISTS_REPLACE);
    file_unmanaged_copy(drupal_get_path('module', 'file_mdm') . '/tests/files/test-exif.jpeg', 'public://', FILE_EXISTS_REPLACE);
    file_unmanaged_copy(drupal_get_path('module', 'file_mdm') . '/tests/files/test-exif.jpeg', 'temporary://', FILE_EXISTS_REPLACE);

    // The image files that will be tested.
    $image_files = [
      [
        // Pass a path instead of the URI.
        'uri' => drupal_get_path('module', 'file_mdm') . '/tests/files/test-exif.jpeg',
        'count_keys' => 48,
        'test_keys' => [
          [
            'Orientation',
            8,
          ],
          [
            'orientation',
            8,
          ],
          [
            'OrIeNtAtIoN',
            8,
          ],
          [
            'ShutterSpeedValue',
            [
              106,
              32,
            ],
          ],
          [
            'ApertureValue',
            [
              128,
              32,
            ],
          ],
          [
            [
              'exif',
              'aperturevalue',
            ],
            [
              128,
              32,
            ],
          ],
          [
            [
              2,
              'aperturevalue',
            ],
            [
              128,
              32,
            ],
          ],
          [
            [
              'exif',
              0x9202,
            ],
            [
              128,
              32,
            ],
          ],
          [
            [
              2,
              0x9202,
            ],
            [
              128,
              32,
            ],
          ],
        ],
      ],
      [
        // Pass a URI.
        'uri' => 'public://test-exif.jpeg',
        'count_keys' => 48,
        'test_keys' => [
          [
            'Orientation',
            8,
          ],
          [
            'ShutterSpeedValue',
            [
              106,
              32,
            ],
          ],
        ],
      ],
      [
        // Remote storage file. Let the file be copied to a local temp copy.
        'uri' => 'dummy-remote://test-exif.jpeg',
        'copy_to_temp' => TRUE,
        'count_keys' => 48,
        'test_keys' => [
          [
            'Orientation',
            8,
          ],
          [
            'ShutterSpeedValue',
            [
              106,
              32,
            ],
          ],
        ],
      ],
      [
        // JPEG Image with GPS data.
        'uri' => drupal_get_path('module', 'file_mdm') . '/tests/files/1024-2006_1011_093752.jpg',
        'count_keys' => 59,
        'test_keys' => [
          [
            'Orientation',
            1,
          ],
          [
            'FocalLength',
            [
              8513,
              256,
            ],
          ],
          [
            'GPSLatitudeRef',
            'S',
          ],
          [
            'GPSLatitude',
            [
              [
                33,
                1,
              ],
              [
                51,
                1,
              ],
              [
                2191,
                100,
              ],
            ],
          ],
          [
            'GPSLongitudeRef',
            'E',
          ],
          [
            'GPSLongitude',
            [
              [
                151,
                1,
              ],
              [
                13,
                1,
              ],
              [
                1173,
                100,
              ],
            ],
          ],
        ],
      ],
      [
        // JPEG Image with no EXIF data.
        'uri' => 'public://image-test.jpg',
        'count_keys' => 0,
        'test_keys' => [],
      ],
      [
        // TIFF image.
        'uri' => drupal_get_path('module', 'file_mdm') . '/tests/files/sample-1.tiff',
        'count_keys' => 11,
        'test_keys' => [
          [
            'Orientation',
            1,
          ],
          [
            'BitsPerSample',
            [
              8,
              8,
              8,
              8,
            ],
          ],
        ],
      ],
      [
        // PNG should not have any data.
        'uri' => 'public://image-test.png',
        'count_keys' => 0,
        'test_keys' => [],
      ],
    ];
    $fmdm = $this->container
      ->get('file_metadata_manager');

    // Walk through test files.
    foreach ($image_files as $image_file) {
      $file_metadata = $fmdm
        ->uri($image_file['uri']);
      if (!$file_metadata) {
        $this
          ->fail("File not found: {$image_file['uri']}");
        continue;
      }
      if (isset($image_file['copy_to_temp'])) {
        $file_metadata
          ->copyUriToTemp();
      }
      $this
        ->assertEquals($image_file['count_keys'], $this
        ->countMetadataKeys($file_metadata, 'exif'));
      foreach ($image_file['test_keys'] as $test) {
        $entry = $file_metadata
          ->getMetadata('exif', $test[0]);
        $this
          ->assertEquals($test[1], $entry ? $entry['value'] : NULL);
      }
    }

    // Test loading metadata from an in-memory object.
    $file_metadata_from = $fmdm
      ->uri($image_files[0]['uri']);
    $metadata = $file_metadata_from
      ->getMetadata('exif');
    $new_file_metadata = $fmdm
      ->uri('public://test-output.jpeg');
    $new_file_metadata
      ->loadMetadata('exif', $metadata);
    $this
      ->assertEquals($image_files[0]['count_keys'], $this
      ->countMetadataKeys($new_file_metadata, 'exif'));
    foreach ($image_files[0]['test_keys'] as $test) {
      $entry = $file_metadata
        ->getMetadata('exif', $test[0]);
      $this
        ->assertEquals($test[1], $new_file_metadata
        ->getMetadata('exif', $test[0])['value']);
    }

    // Test removing metadata.
    $fmdm
      ->release($image_files[0]['uri']);
    $this
      ->assertFalse($fmdm
      ->has($image_files[0]['uri']));
    $file_metadata = $fmdm
      ->uri($image_files[0]['uri']);
    $this
      ->assertEquals($image_files[0]['count_keys'], $this
      ->countMetadataKeys($file_metadata, 'exif'));
    $this
      ->assertTrue($file_metadata
      ->removeMetadata('exif', 'shutterspeedValue'));
    $this
      ->assertTrue($file_metadata
      ->removeMetadata('exif', 'apertureValue'));
    $this
      ->assertFalse($file_metadata
      ->removeMetadata('exif', 'bar'));
    $this
      ->assertEquals($image_files[0]['count_keys'] - 2, $this
      ->countMetadataKeys($file_metadata, 'exif'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'shutterspeedValue'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'apertureValue'));
    $this
      ->assertNotNull($file_metadata
      ->getMetadata('exif', 'orientation'));
  }

  /**
   * Test writing metadata to JPEG file.
   */
  public function testJpegExifSaveToFile() {
    $fmdm = $this->container
      ->get('file_metadata_manager');

    // Copy test file to public://.
    file_unmanaged_copy(drupal_get_path('module', 'image_effects') . '/tests/images/portrait-painting.jpg', 'public://', FILE_EXISTS_REPLACE);
    $file_uri = 'public://portrait-painting.jpg';
    $file_metadata = $fmdm
      ->uri($file_uri);

    // Check values via exif_read_data before operations.
    $data = @exif_read_data($file_uri);
    $this
      ->assertEquals(8, $data['Orientation']);
    $this
      ->assertFalse(isset($data['Artist']));
    $this
      ->assertEquals('Canon', $data['Make']);
    $this
      ->assertEquals(800, $data['ISOSpeedRatings']);

    // Change the Orientation tag from IFD0.
    $this
      ->assertEquals(8, $file_metadata
      ->getMetadata('exif', 'orientation')['value']);
    $this
      ->assertTrue($file_metadata
      ->setMetadata('exif', 'orientation', 4));
    $this
      ->assertEquals(4, $file_metadata
      ->getMetadata('exif', 'orientation')['value']);

    // Add the Artist tag to IFD0.
    $this
      ->assertEquals(48, $this
      ->countMetadataKeys($file_metadata, 'exif'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'artist'));
    $artist_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag('artist');
    $artist = new PelEntryAscii($artist_tag['tag'], 'shot by foo!');
    $file_metadata
      ->setMetadata('exif', 'artist', $artist);
    $this
      ->assertEquals('shot by foo!', $file_metadata
      ->getMetadata('exif', 'artist')['value']);
    $this
      ->assertEquals(49, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Setting an unknown tag leads to failure.
    $this
      ->assertFalse($file_metadata
      ->setMetadata('exif', 'bar', 'qux'));

    // Remove the Make tag from IFD0.
    $this
      ->assertEquals('Canon', $file_metadata
      ->getMetadata('exif', 'make')['value']);
    $this
      ->assertTrue($file_metadata
      ->removeMetadata('exif', 'make'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'make'));
    $this
      ->assertEquals(48, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Add the ImageDescription tag to IFD1.
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', [
      1,
      'imagedescription',
    ]));
    $desc_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag([
      1,
      'imagedescription',
    ]);
    $desc = new PelEntryAscii($desc_tag['tag'], 'awesome!');
    $file_metadata
      ->setMetadata('exif', [
      1,
      'imagedescription',
    ], $desc);
    $this
      ->assertEquals('awesome!', $file_metadata
      ->getMetadata('exif', [
      1,
      'imagedescription',
    ])['value']);
    $this
      ->assertEquals(49, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Remove the Compression tag from IFD1.
    $this
      ->assertEquals(6, $file_metadata
      ->getMetadata('exif', [
      1,
      'compression',
    ])['value']);
    $this
      ->assertTrue($file_metadata
      ->removeMetadata('exif', [
      1,
      'compression',
    ]));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', [
      1,
      'compression',
    ]));
    $this
      ->assertEquals(48, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Add the BrightnessValue tag to EXIF.
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', [
      'exif',
      'brightnessvalue',
    ]));
    $brightness_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag([
      'exif',
      'brightnessvalue',
    ]);
    $brightness = new PelEntrySRational($brightness_tag['tag'], [
      12,
      4,
    ]);
    $file_metadata
      ->setMetadata('exif', [
      'exif',
      'brightnessvalue',
    ], $brightness);
    $this
      ->assertEquals('12/4', $file_metadata
      ->getMetadata('exif', [
      'exif',
      'brightnessvalue',
    ])['text']);
    $this
      ->assertEquals(49, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Remove the ISOSpeedRatings tag from EXIF.
    $this
      ->assertEquals(800, $file_metadata
      ->getMetadata('exif', [
      'exif',
      'isospeedratings',
    ])['value']);
    $this
      ->assertTrue($file_metadata
      ->removeMetadata('exif', [
      'exif',
      'isospeedratings',
    ]));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', [
      'exif',
      'isospeedratings',
    ]));
    $this
      ->assertEquals(48, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Add the RelatedImageFileFormat tag to INTEROP.
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', [
      'interop',
      'RelatedImageFileFormat',
    ]));
    $ff_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag([
      'interop',
      'RelatedImageFileFormat',
    ]);
    $ff = new PelEntryAscii($ff_tag['tag'], 'qux');
    $file_metadata
      ->setMetadata('exif', [
      'interop',
      'RelatedImageFileFormat',
    ], $ff);
    $this
      ->assertEquals('qux', $file_metadata
      ->getMetadata('exif', [
      'interop',
      'RelatedImageFileFormat',
    ])['text']);
    $this
      ->assertEquals(49, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Remove the InteroperabilityIndex tag from INTEROP.
    $this
      ->assertEquals('R98', $file_metadata
      ->getMetadata('exif', [
      'interop',
      'InteroperabilityIndex',
    ])['value']);
    $this
      ->assertTrue($file_metadata
      ->removeMetadata('exif', [
      'interop',
      'InteroperabilityIndex',
    ]));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', [
      'interop',
      'InteroperabilityIndex',
    ]));
    $this
      ->assertEquals(48, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Add Longitude/Latitude tags to GPS.
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'GPSLatitudeRef'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'GPSLatitude'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'GPSLongitudeRef'));
    $this
      ->assertNull($file_metadata
      ->getMetadata('exif', 'GPSLongitude'));
    $atr_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag('GPSLatitudeRef');
    $at_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag('GPSLatitude');
    $otr_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag('GPSLongitudeRef');
    $ot_tag = $this->container
      ->get('file_mdm_exif.tag_mapper')
      ->resolveKeyToIfdAndTag('GPSLongitude');
    $atr = new PelEntryAscii($atr_tag['tag'], 'N');
    $at = new PelEntryRational($at_tag['tag'], [
      46,
      1,
    ], [
      37,
      1,
    ], [
      59448,
      10000,
    ]);
    $otr = new PelEntryAscii($otr_tag['tag'], 'E');
    $ot = new PelEntryRational($ot_tag['tag'], [
      12,
      1,
    ], [
      17,
      1,
    ], [
      488112,
      10000,
    ]);
    $file_metadata
      ->setMetadata('exif', 'GPSLatitudeRef', $atr);
    $file_metadata
      ->setMetadata('exif', 'GPSLatitude', $at);
    $file_metadata
      ->setMetadata('exif', 'GPSLongitudeRef', $otr);
    $file_metadata
      ->setMetadata('exif', 'GPSLongitude', $ot);
    $this
      ->assertEquals('N', $file_metadata
      ->getMetadata('exif', 'GPSLatitudeRef')['text']);
    $this
      ->assertNotNull($file_metadata
      ->getMetadata('exif', 'GPSLatitude')['text']);
    $this
      ->assertEquals('E', $file_metadata
      ->getMetadata('exif', 'GPSLongitudeRef')['text']);
    $this
      ->assertNotNull($file_metadata
      ->getMetadata('exif', 'GPSLongitude')['text']);
    $this
      ->assertEquals(52, $this
      ->countMetadataKeys($file_metadata, 'exif'));

    // Save metadata to file.
    $this
      ->assertTrue($file_metadata
      ->saveMetadataToFile('exif'));

    // Check results via exif_read_data.
    $data = @exif_read_data($file_uri);
    $this
      ->assertEquals(4, $data['Orientation']);
    $this
      ->assertEquals('shot by foo!', $data['Artist']);
    $this
      ->assertFalse(isset($data['Make']));
    $this
      ->assertEquals('12/4', $data['BrightnessValue']);
    $this
      ->assertFalse(isset($data['ISOSpeedRatings']));
    $this
      ->assertEquals('qux', $data['RelatedFileFormat']);
    $this
      ->assertFalse(isset($data['InterOperabilityIndex']));
    $this
      ->assertEquals('N', $data['GPSLatitudeRef']);
    $this
      ->assertEquals([
      '46/1',
      '37/1',
      '59448/10000',
    ], $data['GPSLatitude']);
    $this
      ->assertEquals('E', $data['GPSLongitudeRef']);
    $this
      ->assertEquals([
      '12/1',
      '17/1',
      '488112/10000',
    ], $data['GPSLongitude']);

    // Test writing metadata to a file that has no EXIF info.
    file_unmanaged_copy(drupal_get_path('module', 'simpletest') . '/files/image-2.jpg', 'public://', FILE_EXISTS_REPLACE);
    $test_2 = $fmdm
      ->uri('public://image-2.jpg');
    $this
      ->assertEquals(0, $this
      ->countMetadataKeys($test_2, 'exif'));

    // Load EXIF metadata from previous file processed.
    $test_2
      ->loadMetadata('exif', $file_metadata
      ->getMetadata('exif'));

    // Save metadata to file.
    $this
      ->assertTrue($test_2
      ->saveMetadataToFile('exif'));
    $this
      ->assertEquals(52, $this
      ->countMetadataKeys($test_2, 'exif'));

    // Check results via exif_read_data.
    $data = @exif_read_data('public://image-2.jpg');
    $this
      ->assertEquals(4, $data['Orientation']);
    $this
      ->assertEquals('shot by foo!', $data['Artist']);
    $this
      ->assertEquals('12/4', $data['BrightnessValue']);
    $this
      ->assertEquals('qux', $data['RelatedFileFormat']);
    $this
      ->assertEquals('N', $data['GPSLatitudeRef']);
    $this
      ->assertEquals([
      '46/1',
      '37/1',
      '59448/10000',
    ], $data['GPSLatitude']);
    $this
      ->assertEquals('E', $data['GPSLongitudeRef']);
    $this
      ->assertEquals([
      '12/1',
      '17/1',
      '488112/10000',
    ], $data['GPSLongitude']);

    // Check that after save, file metadata is retrieved from file first time,
    // then from cache in further requests.
    $file_metadata = NULL;
    $this
      ->assertTrue($fmdm
      ->release($file_uri));
    $file_metadata = $fmdm
      ->uri($file_uri);
    $this
      ->assertEquals(52, $this
      ->countMetadataKeys($file_metadata, 'exif'));
    $this
      ->assertSame(FileMetadataInterface::LOADED_FROM_FILE, $file_metadata
      ->isMetadataLoaded('exif'));
    $file_metadata = NULL;
    $this
      ->assertTrue($fmdm
      ->release($file_uri));
    $file_metadata = $fmdm
      ->uri($file_uri);
    $this
      ->assertEquals(52, $this
      ->countMetadataKeys($file_metadata, 'exif'));
    $this
      ->assertSame(FileMetadataInterface::LOADED_FROM_CACHE, $file_metadata
      ->isMetadataLoaded('exif'));
  }

  /**
   * Test writing metadata to TIFF file.
   */
  public function testTiffExifSaveToFile() {
    $fmdm = $this->container
      ->get('file_metadata_manager');

    // Copy test file to public://.
    file_unmanaged_copy(drupal_get_path('module', 'file_mdm') . '/tests/files/sample-1.tiff', 'public://', FILE_EXISTS_REPLACE);
    $file_uri = 'public://sample-1.tiff';
    $file_metadata = $fmdm
      ->uri($file_uri);

    // Check values via exif_read_data before operations.
    $data = @exif_read_data($file_uri);
    $this
      ->assertEquals(1, $data['Orientation']);
    $this
      ->assertEquals(2, $data['PhotometricInterpretation']);

    // Change tags from IFD0.
    $this
      ->assertEquals(1, $file_metadata
      ->getMetadata('exif', 'orientation')['value']);
    $this
      ->assertTrue($file_metadata
      ->setMetadata('exif', 'orientation', 4));
    $this
      ->assertEquals(4, $file_metadata
      ->getMetadata('exif', 'orientation')['value']);
    $this
      ->assertEquals(2, $file_metadata
      ->getMetadata('exif', 'PhotometricInterpretation')['value']);
    $this
      ->assertTrue($file_metadata
      ->setMetadata('exif', 'PhotometricInterpretation', 4));
    $this
      ->assertEquals(4, $file_metadata
      ->getMetadata('exif', 'PhotometricInterpretation')['value']);

    // Save metadata to file.
    $this
      ->assertTrue($file_metadata
      ->saveMetadataToFile('exif'));

    // Check results via exif_read_data.
    $data = @exif_read_data($file_uri);
    $this
      ->assertEquals(4, $data['Orientation']);
    $this
      ->assertEquals(4, $data['PhotometricInterpretation']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssertContentTrait::$content protected property The current raw content.
AssertContentTrait::$drupalSettings protected property The drupalSettings value from the current raw $content.
AssertContentTrait::$elements protected property The XML structure parsed from the current raw $content. 1
AssertContentTrait::$plainTextContent protected property The plain-text content of raw $content (text nodes).
AssertContentTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertContentTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertContentTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertContentTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertContentTrait::assertLink protected function Passes if a link with the specified label is found.
AssertContentTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertContentTrait::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
AssertContentTrait::assertNoEscaped protected function Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertNoField protected function Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertContentTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertContentTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertContentTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertContentTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertContentTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertContentTrait::assertNoLinkByHrefInMainRegion protected function Passes if a link containing a given href is not found in the main region.
AssertContentTrait::assertNoOption protected function Asserts that a select option in the current page does not exist.
AssertContentTrait::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
AssertContentTrait::assertNoPattern protected function Triggers a pass if the perl regex pattern is not found in raw content.
AssertContentTrait::assertNoRaw protected function Passes if the raw text is NOT found on the loaded page, fail otherwise.
AssertContentTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text.
AssertContentTrait::assertNoTitle protected function Pass if the page title is not the given string.
AssertContentTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertContentTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertContentTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionSelectedWithDrupalSelector protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionWithDrupalSelector protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertContentTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise.
AssertContentTrait::assertText protected function Passes if the page (with HTML stripped) contains the text.
AssertContentTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern protected function Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertThemeOutput protected function Asserts themed output.
AssertContentTrait::assertTitle protected function Pass if the page title is the given string.
AssertContentTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertContentTrait::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
AssertContentTrait::buildXPathQuery protected function Builds an XPath query.
AssertContentTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertContentTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
AssertContentTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertContentTrait::getDrupalSettings protected function Gets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::getRawContent protected function Gets the current raw content.
AssertContentTrait::getSelectedItem protected function Get the selected value from a select field.
AssertContentTrait::getTextContent protected function Retrieves the plain-text content from the current raw content.
AssertContentTrait::getUrl protected function Get the current URL from the cURL handler. 1
AssertContentTrait::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
AssertContentTrait::removeWhiteSpace protected function Removes all white-space between HTML tags from the raw content.
AssertContentTrait::setDrupalSettings protected function Sets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::setRawContent protected function Sets the raw content (e.g. HTML).
AssertContentTrait::xpath protected function Performs an xpath search on the contents of the internal browser.
AssertHelperTrait::castSafeStrings protected static function Casts MarkupInterface objects into strings.
AssertLegacyTrait::assert protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::assertEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead.
AssertLegacyTrait::assertIdenticalObject protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertNotEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead.
AssertLegacyTrait::assertNotIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead.
AssertLegacyTrait::pass protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::verbose protected function
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
FileMetadataExifTest::$modules public static property Modules to enable. Overrides KernelTestBase::$modules
FileMetadataExifTest::setUp public function Overrides FileMetadataManagerTestBase::setUp
FileMetadataExifTest::testExifPlugin public function Test EXIF plugin.
FileMetadataExifTest::testJpegExifSaveToFile public function Test writing metadata to JPEG file.
FileMetadataExifTest::testTiffExifSaveToFile public function Test writing metadata to TIFF file.
FileMetadataManagerTestBase::countMetadataKeys protected function Returns the count of metadata keys found in the file.
KernelTestBase::$backupGlobals protected property Back up and restore any global variables that may be changed by tests.
KernelTestBase::$backupStaticAttributes protected property Back up and restore static class properties that may be changed by tests.
KernelTestBase::$backupStaticAttributesBlacklist protected property Contains a few static class properties for performance.
KernelTestBase::$classLoader protected property
KernelTestBase::$configImporter protected property @todo Move into Config test base class. 7
KernelTestBase::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking.
KernelTestBase::$container protected property
KernelTestBase::$databasePrefix protected property
KernelTestBase::$preserveGlobalState protected property Do not forward any global state from the parent process to the processes that run the actual tests.
KernelTestBase::$root protected property The app root.
KernelTestBase::$runTestInSeparateProcess protected property Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property.
KernelTestBase::$siteDirectory protected property
KernelTestBase::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 6
KernelTestBase::$vfsRoot protected property The virtual filesystem root directory.
KernelTestBase::assertPostConditions protected function 1
KernelTestBase::bootEnvironment protected function Bootstraps a basic test environment.
KernelTestBase::bootKernel private function Bootstraps a kernel for a test.
KernelTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
KernelTestBase::disableModules protected function Disables modules for this test.
KernelTestBase::enableModules protected function Enables modules for this test.
KernelTestBase::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
KernelTestBase::getDatabaseConnectionInfo protected function Returns the Database connection info to be used for this test. 1
KernelTestBase::getDatabasePrefix public function
KernelTestBase::getExtensionsForModules private function Returns Extension objects for $modules to enable.
KernelTestBase::getModulesToEnable private static function Returns the modules to enable for this test.
KernelTestBase::initFileCache protected function Initializes the FileCache component.
KernelTestBase::installConfig protected function Installs default configuration for a given list of modules.
KernelTestBase::installEntitySchema protected function Installs the storage schema for a specific entity type.
KernelTestBase::installSchema protected function Installs database tables from a module schema definition.
KernelTestBase::isTestInIsolation Deprecated protected function Returns whether the current test method is running in a separate process.
KernelTestBase::prepareTemplate protected function
KernelTestBase::register public function Registers test-specific services. Overrides ServiceProviderInterface::register 26
KernelTestBase::render protected function Renders a render array. 1
KernelTestBase::setInstallProfile protected function Sets the install profile and rebuilds the container to update it.
KernelTestBase::setSetting protected function Sets an in-memory Settings variable.
KernelTestBase::setUpBeforeClass public static function 1
KernelTestBase::setUpFilesystem protected function Sets up the filesystem, so things like the file directory. 2
KernelTestBase::stop protected function Stops test execution.
KernelTestBase::tearDown protected function 6
KernelTestBase::tearDownCloseDatabaseConnection public function @after
KernelTestBase::vfsDump protected function Dumps the current state of the virtual filesystem to STDOUT.
KernelTestBase::__get Deprecated public function BC: Automatically resolve former KernelTestBase class properties.
KernelTestBase::__sleep public function Prevents serializing any properties.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
RandomGeneratorTrait::$randomGenerator protected property The random generator.
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. 1
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.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestRequirementsTrait::checkModuleRequirements private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements protected function Check module requirements for the Drupal use case. 1
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.