diff --git a/field_example/src/Tests/ColorBackgroundFormatterTest.php b/field_example/src/Tests/ColorBackgroundFormatterTest.php deleted file mode 100644 index d8ef776..0000000 --- a/field_example/src/Tests/ColorBackgroundFormatterTest.php +++ /dev/null @@ -1,96 +0,0 @@ -drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_colorpicker', '1', 'field_example_color_background'); - - // Login with Author user for content creation. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Details to be submitted for content creation. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value]' => '#00ff00', - ); - - // Submit the content creation form. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify color. - $this->assertText(t('The content area color has been changed to #00ff00'), 'Verify the color'); - } - - /** - * Test scenarios in Field example. - * - * - Creates a content type. - * - Adds a multivalued field_example_rgb to it. - * - Creates a node of the new type. - * - Populates the multivalued field with two items. - * - Tests the result. - */ - public function testMultiValueField() { - - // Login with Admin and create a field. - $this->drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_colorpicker', '-1', 'field_example_color_background'); - - // Login with Author user for content creation. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Details to be submitted for content creation. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value]' => '#00ff00', - ); - - // Add another field value. - $this->drupalPostForm(NULL, $edit, t('Add another item')); - - // Set value for newly added item. - $edit = array( - 'field_' . $this->fieldName . '[1][value]' => '#ffff4f', - ); - - // Submit the content creation form. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify color. - $this->assertText(t('The content area color has been changed to #00ff00'), 'Verify the color of field 1'); - $this->assertText(t('The content area color has been changed to #ffff4f'), 'Verify the color of field 2'); - } - -} diff --git a/field_example/src/Tests/ColorPickerWidgetTest.php b/field_example/src/Tests/ColorPickerWidgetTest.php deleted file mode 100644 index a3b969d..0000000 --- a/field_example/src/Tests/ColorPickerWidgetTest.php +++ /dev/null @@ -1,98 +0,0 @@ -drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_colorpicker', '1'); - - // Login with Author user for content creation. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Details to be submitted for content creation. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value]' => '#00ff00', - ); - - // Submit the content creation form. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify color. - $this->assertText(t('The color code in this field is #00ff00'), 'Verify the color'); - } - - /** - * Test scenarios in Field example. - * - * - Creates a content type. - * - Adds a multivalued field_example_rgb to it. - * - Creates a node of the new type. - * - Populates the multivalued field with two items. - * - Tests the result. - */ - public function testMultiValueField() { - - // Login with Admin and create a field. - $this->drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_colorpicker', '-1'); - - // Login with Author user for content creation. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Details to be submitted for content creation. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value]' => '#00ff00', - ); - - // Add another field value. - $this->drupalPostForm(NULL, $edit, t('Add another item')); - - // Set value for newly added item. - $edit = array( - 'field_' . $this->fieldName . '[1][value]' => '#ffffff', - ); - - // Submit the content creation form. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify color. - $this->assertText(t('The color code in this field is #00ff00'), 'Verify the color of field 1'); - $this->assertText(t('The color code in this field is #ffffff'), 'Verify the color of field 2'); - } - -} diff --git a/field_example/src/Tests/FieldExampleMenuTest.php b/field_example/src/Tests/FieldExampleMenuTest.php deleted file mode 100644 index 825af7f..0000000 --- a/field_example/src/Tests/FieldExampleMenuTest.php +++ /dev/null @@ -1,49 +0,0 @@ -drupalGet(''); - $this->assertLinkByHref('examples/field-example'); - } - - /** - * Tests field_example menus. - */ - public function testBlockExampleMenu() { - $this->drupalGet('examples/field-example'); - $this->assertResponse(200, 'Description page exists.'); - } - -} diff --git a/field_example/src/Tests/Text3WidgetTest.php b/field_example/src/Tests/Text3WidgetTest.php deleted file mode 100644 index c3c2dd2..0000000 --- a/field_example/src/Tests/Text3WidgetTest.php +++ /dev/null @@ -1,103 +0,0 @@ -drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_3text', '1'); - // Post-condition: Content type now has the desired field. - // Switch to the author user to create content with this type and field. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Fill the create form. - $title = 'test_title'; - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value][r]' => '00', - 'field_' . $this->fieldName . '[0][value][g]' => '0a', - 'field_' . $this->fieldName . '[0][value][b]' => '01', - ); - - // Create the content. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify the value is shown when viewing this node. - $field_p = $this->xpath("//div[contains(@class,'field--type-field-example-rgb')]/div/p"); - $this->assertEqual((string) $field_p[0], "The color code in this field is #000a01"); - } - - /** - * Test basic functionality of the example field. - * - * - Creates a content type. - * - Adds a single-valued field_example_rgb to it. - * - Adds a multivalued field_example_rgb to it. - * - Creates a node of the new type. - * - Populates the single-valued field. - * - Populates the multivalued field with two items. - * - Tests the result. - */ - public function testMultiValueField() { - // Add a single field as administrator user. - $this->drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_3text', '-1'); - // Post-condition: Content type now has the desired field. - // Switch to the author user to create content with this type and field. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Fill the create form. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value][r]' => '00', - 'field_' . $this->fieldName . '[0][value][g]' => 'ff', - 'field_' . $this->fieldName . '[0][value][b]' => '00', - ); - - // Add a 2nd item to the multivalue field, so hit "add another". - $this->drupalPostForm(NULL, $edit, t('Add another item')); - $edit = array( - 'field_' . $this->fieldName . '[1][value][r]' => 'ff', - 'field_' . $this->fieldName . '[1][value][g]' => 'ff', - 'field_' . $this->fieldName . '[1][value][b]' => 'ff', - ); - - // Create the content. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify the values are shown when viewing this node. - $field_p = $this->xpath("//div[contains(@class,'field--type-field-example-rgb')]/div/div/p"); - $this->assertEqual((string) $field_p[0], "The color code in this field is #00ff00"); - $this->assertEqual((string) $field_p[1], "The color code in this field is #ffffff"); - } - -} diff --git a/field_example/src/Tests/TextWidgetTest.php b/field_example/src/Tests/TextWidgetTest.php deleted file mode 100644 index f3521c2..0000000 --- a/field_example/src/Tests/TextWidgetTest.php +++ /dev/null @@ -1,102 +0,0 @@ -drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_text', '1'); - - // Now that we have a content type with the desired field, switch to the - // author user to create content with it. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Add a node. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value]' => '#000001', - ); - - // Create the content. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify the value is shown when viewing this node. - $field_p = $this->xpath("//div[contains(@class,'field--type-field-example-rgb')]/div/p"); - $this->assertEqual((string) $field_p[0], "The color code in this field is #000001"); - } - - /** - * Test basic functionality of the example field. - * - * - Creates a content type. - * - Adds a single-valued field_example_rgb to it. - * - Adds a multivalued field_example_rgb to it. - * - Creates a node of the new type. - * - Populates the single-valued field. - * - Populates the multivalued field with two items. - * - Tests the result. - */ - public function testMultiValueField() { - // Add a single field as administrator user. - $this->drupalLogin($this->administratorAccount); - $this->fieldName = $this->createField('field_example_rgb', 'field_example_text', '-1'); - - // Now that we have a content type with the desired field, switch to the - // author user to create content with it. - $this->drupalLogin($this->authorAccount); - $this->drupalGet('node/add/' . $this->contentTypeName); - - // Add a node. - $title = $this->randomMachineName(20); - $edit = array( - 'title[0][value]' => $title, - 'field_' . $this->fieldName . '[0][value]' => '#00ff00', - ); - - // We want to add a 2nd item to the multivalue field, so hit "add another". - $this->drupalPostForm(NULL, $edit, t('Add another item')); - - $edit = array( - 'field_' . $this->fieldName . '[1][value]' => '#ffffff', - ); - - // Now we can fill in the second item in the multivalue field and save. - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText(t('@type @title has been created', array('@type' => $this->contentTypeName, '@title' => $title))); - - // Verify the value is shown when viewing this node. - $field_p = $this->xpath("//div[contains(@class,'field--type-field-example-rgb')]/div/div/p"); - $this->assertEqual((string) $field_p[0], "The color code in this field is #00ff00"); - $this->assertEqual((string) $field_p[1], "The color code in this field is #ffffff"); - } - -}