You are here

protected function ContentTypeBuilderTest::testContentTypeCreate in Schema.org configuration tool (RDF UI) 8

Tests submission of Content Type Builder and creation of content type.

File

rdf_builder/src/Tests/ContentTypeBuilderTest.php, line 52

Class

ContentTypeBuilderTest
Tests the Content Type Builder.

Namespace

Drupal\rdf_builder\Tests

Code

protected function testContentTypeCreate() {
  $this
    ->editFormOne();
  foreach (array(
    'email',
    'name',
  ) as $element) {
    $this
      ->assertText($element, format_string('property "@element" of "@type" was found.', array(
      '@element' => $element,
      '@type' => $this->rdf_type,
    )));
  }
  $this
    ->assertFieldByName('fields[schema:email][enable]', NULL, 'Checkbox for property found');
  $this
    ->assertFieldByName('fields[schema:email][type]', NULL, 'Dropdown list for data type found.');
  $edit = array(
    'fields[schema:email][enable]' => '1',
    'fields[schema:email][type]' => 'email',
    'fields[schema:name][enable]' => '1',
    'fields[schema:name][type]' => '',
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->assertText("Create field: you need to provide a data type for name", 'Form validated and errors displayed.');
  $this
    ->assertUrl($this->uri, array(), 'Stayed on same page after incorrect submission.');
  $edit['fields[schema:name][type]'] = 'text';
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  //$this->assertUrl('admin/structure/types', array(), 'Redirected to correct url upon correct submission.');
  $this
    ->assertText('Content Type Person created', 'Successful content type creation message displayed');
}