assertNotRegExp() public static method

Asserts that a string does not match a given regular expression.
public static assertNotRegExp ( string $pattern, string $string, string $message = '' )
$pattern string
$string string
$message string
 /**
  * @Given No entry was set
  */
 public function noEntryExists()
 {
     $sitemap = $this->app['sitemap']->generate(false);
     PHPUnit_Framework_Assert::assertNotRegExp('/\\<url\\>/', $sitemap);
 }
示例#2
0
 /**
  * Checks that string not match with pattern
  *
  * @param string $pattern
  * @param string $string
  * @param string $message
  */
 protected function assertNotRegExp($pattern, $string, $message = '')
 {
     \PHPUnit_Framework_Assert::assertNotRegExp($pattern, $string, $message);
 }
示例#3
0
/**
 * Asserts that a string does not match a given regular expression.
 *
 * @param  string $pattern
 * @param  string $string
 * @param  string $message
 * @since  Method available since Release 2.1.0
 */
function assertNotRegExp($pattern, $string, $message = '')
{
    return PHPUnit_Framework_Assert::assertNotRegExp($pattern, $string, $message);
}
示例#4
0
 public function dontSeeCurrentUrlMatches($uri)
 {
     \PHPUnit_Framework_Assert::assertNotRegExp($uri, $this->_getCurrentUri());
 }
 protected function assertCommand($command, $arguments, $info)
 {
     $method = $info['originalMethod'];
     $result = $this->__call($method, $arguments);
     if ($info['isBoolean']) {
         if (!isset($info['negative']) || !$info['negative']) {
             PHPUnit_Framework_Assert::assertTrue($result);
         } else {
             PHPUnit_Framework_Assert::assertFalse($result);
         }
     } else {
         $expected = array_pop($arguments);
         if (strpos($expected, 'exact:') === 0) {
             $expected = substr($expected, strlen('exact:'));
             if (!isset($info['negative']) || !$info['negative']) {
                 PHPUnit_Framework_Assert::assertEquals($expected, $result);
             } else {
                 PHPUnit_Framework_Assert::assertNotEquals($expected, $result);
             }
         } else {
             if (strpos($expected, 'regexp:') === 0) {
                 $expected = substr($expected, strlen('regexp:'));
             } else {
                 if (strpos($expected, 'glob:') === 0) {
                     $expected = substr($expected, strlen('glob:'));
                 }
                 $expected = str_replace(array('*', '?'), array('.*', '.?'), $expected);
             }
             $expected = str_replace('/', '\\/', $expected);
             if (!isset($info['negative']) || !$info['negative']) {
                 PHPUnit_Framework_Assert::assertRegExp('/' . $expected . '/', $result);
             } else {
                 PHPUnit_Framework_Assert::assertNotRegExp('/' . $expected . '/', $result);
             }
         }
     }
 }
 /**
  * Checks that response body doesn't contains specific text.
  *
  * @param string $text
  *
  * @Then /^(?:the )?response should not contain "([^"]*)"$/
  */
 public function theResponseShouldNotContain($text)
 {
     $expectedRegexp = '/' . preg_quote($text) . '/';
     $actual = (string) $this->response->getBody();
     Assertions::assertNotRegExp($expectedRegexp, $actual);
 }
示例#7
0
 protected function assertCommand($command, $arguments, $info)
 {
     $method = $info['originalMethod'];
     $requiresTarget = $info['requiresTarget'];
     $result = $this->__call($method, $arguments);
     if ($info['isBoolean']) {
         if (!isset($info['negative']) || !$info['negative']) {
             PHPUnit_Framework_Assert::assertTrue($result, $arguments[count($arguments) - 1]);
         } else {
             PHPUnit_Framework_Assert::assertFalse($result, $arguments[count($arguments) - 1]);
         }
     } else {
         if ($requiresTarget === TRUE) {
             $expected = $arguments[1];
         } else {
             $expected = $arguments[0];
         }
         if (strpos($expected, 'exact:') === 0) {
             $expected = substr($expected, strlen('exact:'));
             if (!isset($info['negative']) || !$info['negative']) {
                 PHPUnit_Framework_Assert::assertEquals($expected, $result);
             } else {
                 PHPUnit_Framework_Assert::assertNotEquals($expected, $result);
             }
         } else {
             $caseInsensitive = FALSE;
             if (strpos($expected, 'regexp:') === 0) {
                 $expected = substr($expected, strlen('regexp:'));
             } else {
                 if (strpos($expected, 'regexpi:') === 0) {
                     $expected = substr($expected, strlen('regexpi:'));
                     $caseInsensitive = TRUE;
                 } else {
                     if (strpos($expected, 'glob:') === 0) {
                         $expected = substr($expected, strlen('glob:'));
                     }
                     $expected = str_replace(array('*', '?'), array('.*', '.?'), $expected);
                 }
             }
             $expected = '/' . str_replace('/', '\\/', $expected) . '/';
             if ($caseInsensitive) {
                 $expected .= 'i';
             }
             if (!isset($info['negative']) || !$info['negative']) {
                 PHPUnit_Framework_Assert::assertRegExp($expected, $result);
             } else {
                 PHPUnit_Framework_Assert::assertNotRegExp($expected, $result);
             }
         }
     }
 }
示例#8
0
 public function toMatchPattern($pattern)
 {
     if ($this->negate) {
         a::assertNotRegExp($pattern, $this->actual);
     } else {
         a::assertRegExp($pattern, $this->actual);
     }
 }
示例#9
0
 /**
  * Expect that a string does not match a given regular expression.
  *
  * @param string $pattern
  * @param string $message
  *
  * @return Expect
  */
 public function notToMatchRegExp($pattern, $message = '')
 {
     Assert::assertNotRegExp($pattern, $this->value, $message);
     return $this;
 }
示例#10
0
 /**
  * Checks that response body doesn't contains specific text.
  *
  * @param string $text
  *
  * @Then /^(?:the )?response should not contain "([^"]*)"$/
  */
 public function theResponseShouldNotContain($text)
 {
     \PHPUnit_Framework_Assert::assertNotRegExp('/' . preg_quote($text) . '/', $this->browser->getLastResponse()->getContent());
 }