You are here

function RegistryParseFilesTestCase::testRegistryParseFiles in Drupal 7

testRegistryParseFiles

File

modules/simpletest/tests/registry.test, line 99

Class

RegistryParseFilesTestCase

Code

function testRegistryParseFiles() {
  _registry_parse_files($this
    ->getFiles());
  foreach ($this->fileTypes as $fileType) {

    // Test that we have all the right resources.
    foreach (array(
      'className',
      'interfaceName',
    ) as $resource) {
      $foundName = db_query('SELECT name FROM {registry} WHERE name = :name', array(
        ':name' => $this->{$fileType}->{$resource},
      ))
        ->fetchField();
      $this
        ->assertTrue($this->{$fileType}->{$resource} == $foundName, t('Resource "@resource" found.', array(
        '@resource' => $this->{$fileType}->{$resource},
      )));
    }

    // Test that we have the right hash.
    $hash = db_query('SELECT hash FROM {registry_file} WHERE filename = :filename', array(
      ':filename' => $this->{$fileType}->fileName,
    ))
      ->fetchField();
    $this
      ->assertTrue(hash('sha256', $this->{$fileType}->contents) == $hash, t('sha-256 for "@filename" matched.' . $fileType . $hash, array(
      '@filename' => $this->{$fileType}->fileName,
    )));
  }
}