/**
  * @Then the cachecontrol header should include the public directive
  */
 public function itShouldBePublic()
 {
     $rawCacheControl = $this->getSession()->getResponseHeader('cache-control');
     assertNotNull($rawCacheControl, 'I\'m not able to find the cache-control header!');
     assertNotContains('private', $rawCacheControl, 'The cache-control header should not include the "private" directive!');
     assertContains('public', $rawCacheControl, 'The cache-control header should include the "public" directive!');
 }
 /**
  * @Then /^the "(?P<role>[^"]*)" role should not have the permission "(?P<permission>[^"]*)"$/
  */
 public function theRoleShouldNotHaveThePermission($role, $permission)
 {
     $rolesWithPermission = user_roles(FALSE, $permission);
     assertNotContains(strtolower($role), $rolesWithPermission);
 }
Exemplo n.º 3
0
 /**
  * Checks, that element with specified CSS doesn't contain specified text.
  *
  * @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
  */
 public function assertElementNotContainsText($element, $text)
 {
     $node = $this->getSession()->getPage()->find('css', $element);
     $text = str_replace('\\"', '"', $text);
     if (null === $node) {
         throw new ElementNotFoundException($this->getSession(), 'element', 'css', $element);
     }
     try {
         assertNotContains($text, $node->getText());
     } catch (AssertException $e) {
         $message = sprintf('The text "%s" appears in the text of the element matching css "%s", but it should not.', $text, $element);
         throw new ElementTextException($message, $this->getSession(), $node, $e);
     }
 }
 /**
  * @Then Asserts the array :arg1 does not contain a :arg2.
  * @param $needle
  * @param $haystack
  */
 public function assertNotContains($haystack, $needle)
 {
     assertNotContains($needle, $haystack, sprintf("Assert the array [%s] don't contain [%s], but have [%s].", print_r($haystack, true), $needle, join(',', array_keys($haystack))));
 }
 /**
  * @test(expectedFail=true)
  * @profile(fork)
  */
 public function testAssertNotContainsFailed()
 {
     assertNotContains('needleinhaystack', 'needle');
     assertNotContains('hayaroundneedleinstack', 'needle');
     assertNotContains('haystackinfrontofneedle', 'needle');
     assertNotContains(array('foo' => array('key' => 'needle')), 'needle');
     assertNotContains(array('foo' => array('needle' => 'value')), 'needle');
 }
 /**
  * Example: Then the email should contain the following data:
  * | row1 |
  * | row2 |
  * Assumes an email has been identified by a previous step.
  * @Then /^the email should (not |)contain the following data:$/
  */
 public function theEmailContainFollowingData($negate, TableNode $table)
 {
     if (!$this->lastMatchedEmail) {
         throw new \LogicException('No matched email found from previous step');
     }
     $email = $this->lastMatchedEmail;
     $emailContent = null;
     if ($email->Content) {
         $emailContent = $email->Content;
     } else {
         $emailContent = $email->PlainContent;
     }
     // Convert html content to plain text
     $emailContent = strip_tags($emailContent);
     $rows = $table->getRows();
     // For "should not contain"
     if (trim($negate)) {
         foreach ($rows as $row) {
             assertNotContains($row[0], $emailContent);
         }
     } else {
         foreach ($rows as $row) {
             assertContains($row[0], $emailContent);
         }
     }
 }
Exemplo n.º 7
0
 /**
  * @Given /^the "([^"]*)" property should not contain "([^"]*)"$/
  */
 public function thePropertyShouldNotContain($property, $expectedValue)
 {
     $payload = $this->getScopePayload();
     $actualValue = $this->arrayGet($payload, $property);
     // if the property is actually an array, use JSON so we look in it deep
     $actualValue = is_array($actualValue) ? json_encode($actualValue, JSON_PRETTY_PRINT) : $actualValue;
     assertNotContains($expectedValue, $actualValue, "Asserting the [{$property}] property in current scope does not contain [{$expectedValue}]: " . json_encode($payload));
 }
Exemplo n.º 8
0
 /**
  * Checks, that no elements with specified CSS contains specified text.
  *
  * @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in any "(?P<element>[^"]*)" element$/
  */
 public function assertNoElementContainsText($element, $text)
 {
     $text = str_replace('\\"', '"', $text);
     $elementsText = $this->getAllElementsText($element);
     try {
         assertNotContains($text, $elementsText);
     } catch (AssertException $e) {
         $message = sprintf('The text "%s" was found in the text of any element matching css "%s"', $text, $element);
         throw new \Behat\Mink\Exception\ExpectationException($message, $this->getSession(), $e);
     }
 }
Exemplo n.º 9
0
    exec($command, $world->output, $world->return);
    // Remove formatting & time from output
    $world->output = trim(implode("\n", $world->output));
});
$steps->Then('/^display last command exit code$/', function ($world) {
    $world->printDebug("`" . $world->command . "`  =>  " . $world->return);
});
$steps->Then('/^display last command output$/', function ($world) {
    $world->printDebug("`" . $world->command . "`:\n" . $world->output);
});
$steps->Then('/^it should (fail|pass) with:$/', function ($world, $success, $data) {
    if ('fail' === $success) {
        assertNotEquals(0, $world->return);
    } else {
        assertEquals(0, $world->return);
    }
    assertEquals((string) $data, $world->output);
});
$steps->Then('/^it should (fail|pass)$/', function ($world, $success) {
    if ('fail' === $success) {
        assertNotEquals(0, $world->return);
    } else {
        assertEquals(0, $world->return);
    }
});
$steps->Then('/^the output should contain$/', function ($world, $text) {
    assertContains($text, $world->output);
});
$steps->Then('/^the output should not contain$/', function ($world, $text) {
    assertNotContains($text, $world->output);
});
Exemplo n.º 10
0
        $text = preg_replace_callback('/\\+[fd] [^ ]+/', function ($matches) {
            return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
        }, (string) $text);
    }
    try {
        assertContains((string) $text, $world->output);
    } catch (Exception $e) {
        $diff = PHPUnit_Framework_TestFailure::exceptionToString($e);
        throw new Exception($diff, $e->getCode(), $e);
    }
});
$steps->Then('/^the output should not contain:$/', function ($world, $text) {
    // windows path fix
    if ('/' !== DIRECTORY_SEPARATOR) {
        $text = preg_replace_callback('/ features\\/[^\\n ]+/', function ($matches) {
            return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
        }, (string) $text);
    }
    try {
        assertNotContains((string) $text, $world->output);
    } catch (Exception $e) {
        $diff = PHPUnit_Framework_TestFailure::exceptionToString($e);
        throw new Exception($diff, $e->getCode(), $e);
    }
});
$steps->Then('/^display last command exit code$/', function ($world) {
    $world->printDebug("`" . $world->command . "`  =>  " . $world->return);
});
$steps->Then('/^display last command output$/', function ($world) {
    $world->printDebug("`" . $world->command . "`:\n" . $world->output);
});
Exemplo n.º 11
0
 /**
  * Checks, that HTML response doesn't contains specified string.
  *
  * @Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
  */
 public function assertResponseNotContains($text)
 {
     $expected = str_replace('\\"', '"', $text);
     $actual = $this->getSession()->getPage()->getContent();
     try {
         assertNotContains($expected, $actual);
     } catch (AssertException $e) {
         $message = sprintf('The string "%s" appears in the HTML response of this page, but it should not.', $expected);
         throw new ExpectationException($message, $this->getSession(), $e);
     }
 }