diff -u b/src/Tests/MonitoringUITest.php b/src/Tests/MonitoringUITest.php --- b/src/Tests/MonitoringUITest.php +++ b/src/Tests/MonitoringUITest.php @@ -96,7 +96,6 @@ 'type' => 'article', )); $this->drupalGet('admin/config/system/monitoring/sensors/add'); - $this->assertFieldByName('status', TRUE); // Test creation of Node entity aggregator sensor. @@ -124,7 +123,7 @@ $edit['conditions[1][value]'] = '0'; $i = 2; foreach ($node_fields as $field) { - $this->drupalPostForm(NULL, array('settings[entity_type]' => 'node'), t('Add another field')); + $this->drupalPostForm(NULL, array(), t('Add another field')); $edit['settings[verbose_fields][' . $i++ . ']'] = $field->getName(); } $this->drupalPostForm(NULL, $edit, t('Save')); @@ -134,6 +133,7 @@ // Test details page by clicking the link in confirmation message. $this->assertLink(t('Node Entity Aggregator sensor')); $this->clickLink(t('Node Entity Aggregator sensor')); + $this->assertResponse(200); $this->assertText('Result'); $this->assertRaw('nid'); $this->assertRaw('label'); @@ -161,6 +161,24 @@ $this->assertFieldByName('settings[verbose_fields][' . $i++ . ']', $field->getName()); } + // Create a file to test. + $file_path = file_default_scheme() . '://test'; + $contents = "file_put_contents()."; + file_put_contents($file_path, $contents); + + // Test if the file exist. + $this->assertTrue(is_file($file_path)); + + // Create a file entity. + $file = entity_create('file', array( + 'uri' => $file_path, + 'uid' => 1, + )); + $file->save(); + + // Test if the entity was created. + $this->assertTrue($file->id() > 0); + $this->drupalGet('admin/config/system/monitoring/sensors/add'); // Test creation of File entity aggregator sensor. @@ -179,7 +197,7 @@ $edit = array(); $i = 2; foreach ($file_fields as $field) { - $this->drupalPostForm(NULL, array('settings[entity_type]' => 'node'), t('Add another field')); + $this->drupalPostForm(NULL, array(), t('Add another field')); $edit['settings[verbose_fields][' . $i++ . ']'] = $field->getName(); } $this->drupalPostForm(NULL, $edit, t('Save')); @@ -189,6 +207,7 @@ // Test details page by clicking the link in confirmation message. $this->assertLink(t('File Entity Aggregator sensor')); $this->clickLink(t('File Entity Aggregator sensor')); + $this->assertResponse(200); $this->assertText('Result'); $this->assertRaw('label'); $this->assertRaw('uuid'); @@ -198,11 +217,11 @@ $this->assertRaw('created'); // Assert that the output is correct. - $this->assertLink($node->getTitle()); - $this->assertLink($node->getOwner()->getUsername()); - $this->assertText($node->uuid()); - $this->assertText(\Drupal::service('date.formatter')->format($node->getCreatedTime(), 'short')); - $this->assertText($node->getChangedTime()); + $this->assertText($file->getFilename()); + $this->assertText($file->uuid()); + $this->assertText($file->getSize()); + $this->assertText($file->getMimeType()); + $this->assertText(\Drupal::service('date.formatter')->format($file->getCreatedTime(), 'short')); $this->drupalGet('admin/config/system/monitoring/sensors/file_test_sensor'); $i = 2;