You are here

private function PatternsImportTestCase::checkImportedFile in Patterns 7

Same name and namespace in other branches
  1. 7.2 tests/importing/importing.test \PatternsImportTestCase::checkImportedFile()
3 calls to PatternsImportTestCase::checkImportedFile()
PatternsImportTestCase::testImportFileFromFile in tests/importing/importing.test
PatternsImportTestCase::testImportFileFromSource in tests/importing/importing.test
PatternsImportTestCase::testImportFileFromURL in tests/importing/importing.test

File

tests/importing/importing.test, line 94
Tests importing files.

Class

PatternsImportTestCase
@file Tests importing files.

Code

private function checkImportedFile($name, $format, $destination) {
  $this
    ->assertNoText(t('Errors in the name of the pattern'), t('Errors in the name of the patterns found.'));
  $this
    ->assertNoText(t('Destination folder does not exist or is not writable'), t('Destination folder exists and is writable: ') . $destination);

  // TODO: proper t()
  $fullname = $name . '.' . $format;
  $ps = db_select('patterns', 'p')
    ->fields('p')
    ->condition('p.name', $fullname)
    ->execute()
    ->fetchAll();

  // return array of Std objs
  $this
    ->assertEqual(count($ps), 1, t('One imported pattern found'));
  $p = $ps[0];
  $this
    ->assertNotNull($p, t('Imported pattern found in the DB.'));
  $this
    ->assertEqual($p->name, $fullname, t('Imported pattern has the correct name.'));

  // Cleanup
  $deleted = file_unmanaged_delete($destination . $fullname);
  $this
    ->assertTrue($deleted, t('Test files deleted.'));
}