protected function StyleguidePaletteTest::testAddingSwatches in Style Guide 7
Tests adding a new palette.
File
- styleguide_palette/
styleguide_palette.test, line 102 - Tests for styleguide_palette.module.
Class
- StyleguidePaletteTest
- Tests style guide palette functionality.
Code
protected function testAddingSwatches() {
// Check the palette page before any have been added.
$this
->drupalGet('admin/config/user-interface/styleguide-palette');
$this
->assertText(t('There are no swatches yet.'));
// Add a new swatch.
$name = $this
->randomName();
$edit = array(
'name' => $this
->randomName(),
'description' => $this
->randomName(),
'hex' => '#123456',
);
$this
->drupalPost('admin/config/user-interface/styleguide-palette/edit', $edit, t('Save palette'));
$this
->assertText(t('Style guide swatches added.'));
$this
->assertFieldByXPath('//input[@name="palette[' . $edit['name'] . '][hex]"]', $edit['hex'], 'The newly added color swatch is shown.');
// View an existing swatch as a regular user.
$this
->drupalLogin($this->webUser);
$this
->drupalGet('admin/config/user-interface/styleguide-palette');
$this
->assertRaw('<h3 class="styleguide-palette-swatch-name">' . $edit['name'] . '</h3>', 'The swatch name is found.');
$this
->assertRaw('<div class="styleguide-palette-swatch-color" style="background-color: ' . $edit['hex'] . ';"> </div>', 'The swatch sample is found.');
$this
->assertRaw('<div class="styleguide-palette-swatch-description">' . $edit['description'] . '</div>', 'The swatch description is found.');
}