Ejemplo n.º 1
0
 /**
  * Asserts the preview of a media asset field is shown.
  *
  * @Then /^(?:|I )see the "(?P<field>(?:[^"]|\\")*)" preview$/
  */
 public function assertMediaAssetFieldPreview($field)
 {
     $field = str_replace('\\"', '"', $field);
     $label = $this->mink->getSession()->getPage()->find('xpath', '//label[contains(text(), \'' . $field . '\')]');
     $current_element = $label;
     // Ascend back up to the div with class field-type-media.
     do {
         $current_element = $current_element->getParent();
     } while (!$current_element->hasClass('field-type-media'));
     $media_field_div = $current_element;
     $preview_thumbnail = NULL;
     $remove_button = NULL;
     // Try to find the preview thumbnail & remove button (for max. 10 seconds).
     $end = microtime(TRUE) + 10;
     do {
         if (!$preview_thumbnail) {
             $preview_thumbnail = $media_field_div->find('css', 'div.preview div.media-thumbnail');
         }
         if (!$remove_button) {
             $remove_button = $media_field_div->findButton('Remove');
         }
         if (!$preview_thumbnail || !$remove_button) {
             usleep(500);
         }
     } while ((!$preview_thumbnail || !$remove_button) && microtime(TRUE) < $end);
     if (!$preview_thumbnail) {
         throw new Exception(sprintf('Preview thumbnail for field "%s" not found.', $field));
     }
     if (!$remove_button) {
         throw new Exception(sprintf('Remove button for field "%s" not found.', $field));
     }
 }
 /**
  * Gets the cache purge rules overview.
  *
  * @return Element
  *   The table body.
  */
 protected function getCachePurgeRulesOverview()
 {
     return $this->mink->getSession()->getPage()->find('css', 'table#frontend-cache-purge-rules > tbody');
 }