Skip to content

Commit

Permalink
Fix some easy linting things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea R Soper committed Aug 1, 2016
1 parent 320fb13 commit 921e504
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions src/Palantirnet/PalantirBehatExtension/Context/FieldContext.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php
/**
* @file
* Contains assertions to test for field types on a form.
* @file Contains assertions to test for field types on a form.
*
* @copyright Copyright (c) 2016 Palantir.net
*/
namespace Palantirnet\PalantirBehatExtension\Context;

use Behat\Gherkin\Node\TableNode;

/**
* Class FieldContext contains assertions to test for field types on a form.
*
* @package Palantirnet\PalantirBehatExtension\Context
*/
class FieldContext extends SharedDrupalContext {


Expand All @@ -27,13 +31,14 @@ class FieldContext extends SharedDrupalContext {
* "body" checks for the existence of the element, "#edit-body". Note, for
* almost everything this will begin with "field-", like "field-tags".
*
* @Then the form at :path has the expected fields:
* @Then the content type :type has the expected fields:
* @Then the form at :path has the expected fields:
* @Then the content type :type has the expected fields:
*
* @param String $path
* @param TableNode $fieldsTable
* @param String $content_type
*
* @param String $path
* @param TableNode $fieldsTable
* @param String $content_type
* @throws \Exception
* @throws \Exception
*/
public function assertFields($path = '', $content_type = '', TableNode $fieldsTable) {
// Load the page with the form on it.
Expand All @@ -54,13 +59,13 @@ public function assertFields($path = '', $content_type = '', TableNode $fieldsTa
* Test a field on the current page to see if it matches
* the expected HTML field type.
*
* @Then the ":field" field is ":tag"
* @Then the ":field" field is ":tag" with type ":type"
* @Then the ":field" field is ":tag"
* @Then the ":field" field is ":tag" with type ":type"
*
* @param string $field
* @param string $expectedTag
* @param string $expectedType
* @throws Exception
* @param string $field
* @param string $expectedTag
* @param string $expectedType
* @throws Exception
*/
public function assertFieldType($field, $expectedTag, $expectedType = '') {
$callback = 'assert' . ucfirst($expectedTag);
Expand All @@ -74,41 +79,41 @@ public function assertFieldType($field, $expectedTag, $expectedType = '') {
/**
* Verify the field is a textarea.
*
* @param $field
* @param $expectedType
* @throws Exception
* @param $field
* @param $expectedType
* @throws Exception
*/
public function assertTextarea($field, $expectedType) {
$element = $this->getSession()->getPage()->find('css', $field);
if (NULL == $element->find('css', 'textarea.form-textarea')) {
if (null == $element->find('css', 'textarea.form-textarea')) {
throw new Exception(sprintf("Couldn't find %s of type textarea.", $field));
}
}

/**
* Verify the field is an input field of the given type.
*
* @param $field
* @param $expectedType
* @throws Exception
* @param $field
* @param $expectedType
* @throws Exception
*/
public function assertInput($field, $expectedType) {
$element = $this->getSession()->getPage()->find('css', $field);
if (NULL == $element || NULL == $element->find('css', 'input[type="' . $expectedType . '"]')) {
if (null == $element || null == $element->find('css', 'input[type="' . $expectedType . '"]')) {
throw new Exception(sprintf("Couldn't find %s of type %s", $field, $expectedType));
}
}

/**
* Verify the field is a select list.
*
* @param $field
* @param $expectedType
* @throws Exception
* @param $field
* @param $expectedType
* @throws Exception
*/
public function assertSelect($field, $expectedType) {
$element = $this->getSession()->getPage()->find('css', $field);
if (NULL == $element->find('css', 'select.form-select')) {
if (null == $element->find('css', 'select.form-select')) {
throw new Exception(sprintf("Couldn't find %s of type select.", $field));
}
// Verify that the select list is not part of a multivalue widget.
Expand Down

0 comments on commit 921e504

Please sign in to comment.