From c85b14c4586008de8ffad18a55b5f6749798ed64 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Mon, 23 Feb 2015 11:26:06 -0800 Subject: [PATCH] Merge pull request #145 from jhedstrom/various-cleanup Various cleanup Signed-off-by: Jonathan Hedstrom --- src/Drupal/DrupalExtension/Context/DrupalContext.php | 2 +- src/Drupal/DrupalExtension/Context/MessageContext.php | 2 -- src/Drupal/DrupalExtension/Context/RawDrupalContext.php | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Drupal/DrupalExtension/Context/DrupalContext.php b/src/Drupal/DrupalExtension/Context/DrupalContext.php index 1a38711e..4f0f62b1 100644 --- a/src/Drupal/DrupalExtension/Context/DrupalContext.php +++ b/src/Drupal/DrupalExtension/Context/DrupalContext.php @@ -155,7 +155,7 @@ public function assertLoggedInWithPermissions($permissions) { */ public function getTableRow(Element $element, $search) { $rows = $element->findAll('css', 'tr'); - if (!$rows) { + if (empty($rows)) { throw new \Exception(sprintf('No rows found on the page %s', $this->getSession()->getCurrentUrl())); } foreach ($rows as $row) { diff --git a/src/Drupal/DrupalExtension/Context/MessageContext.php b/src/Drupal/DrupalExtension/Context/MessageContext.php index b9a5d99b..025bda3d 100644 --- a/src/Drupal/DrupalExtension/Context/MessageContext.php +++ b/src/Drupal/DrupalExtension/Context/MessageContext.php @@ -275,7 +275,6 @@ private function _assert($message, $selectorId, $exceptionMsgNone, $exceptionMsg throw new \Exception(sprintf($exceptionMsgNone, $this->getSession()->getCurrentUrl())); } foreach ($selectorObjects as $selectorObject) { - $text = $selectorObject->getText(); if (strpos(trim($selectorObject->getText()), $message) !== FALSE) { return; } @@ -300,7 +299,6 @@ private function _assertNot($message, $selectorId, $exceptionMsg) { $selectorObjects = $this->getSession()->getPage()->findAll("css", $selector); if (!empty($selectorObjects)) { foreach ($selectorObjects as $selectorObject) { - $text = $selectorObject->getText(); if (strpos(trim($selectorObject->getText()), $message) !== FALSE) { throw new \Exception(sprintf($exceptionMsg, $this->getSession()->getCurrentUrl(), $message)); } diff --git a/src/Drupal/DrupalExtension/Context/RawDrupalContext.php b/src/Drupal/DrupalExtension/Context/RawDrupalContext.php index 84442384..2a8e062e 100644 --- a/src/Drupal/DrupalExtension/Context/RawDrupalContext.php +++ b/src/Drupal/DrupalExtension/Context/RawDrupalContext.php @@ -54,9 +54,9 @@ class RawDrupalContext extends RawMinkContext implements DrupalAwareInterface { * * A value of FALSE denotes an anonymous user. * - * @var mixed + * @var stdClass|bool */ - protected $user = FALSE; + public $user = FALSE; /** * Keep track of all users that are created so they can easily be removed. @@ -247,7 +247,6 @@ public function nodeCreate($node) { * @param $entity */ public function parseEntityFields($entity_type, $entity) { - $values = array(); foreach ($entity as $field_name => $value) { if ($this->getDriver()->isField($entity_type, $field_name)) { $values = explode(', ', $value); @@ -356,4 +355,5 @@ public function loggedIn() { public function loggedInWithRole($role) { return $this->loggedIn() && $this->user && isset($this->user->role) && $this->user->role == $role; } + }