How to use match method of Not class

Best Mockery code snippet using Not.match

AbstractHttpControllerTestCase.php

Source:AbstractHttpControllerTestCase.php Github

copy

Full Screen

...69 /**70 * Assert response header exists and contains the given string71 *72 * @param string $header73 * @param string $match74 */75 public function assertResponseHeaderContains($header, $match)76 {77 $responseHeader = $this->getResponseHeader($header);78 if (!$responseHeader) {79 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(80 'Failed asserting response header, header "%s" do not exists',81 $header82 ));83 }84 if ($match != $responseHeader->getFieldValue()) {85 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(86 'Failed asserting response header "%s" exists and contains "%s", actual content is "%s"',87 $header,88 $match,89 $responseHeader->getFieldValue()90 ));91 }92 $this->assertEquals($match, $responseHeader->getFieldValue());93 }94 /**95 * Assert response header exists and contains the given string96 *97 * @param string $header98 * @param string $match99 */100 public function assertNotResponseHeaderContains($header, $match)101 {102 $responseHeader = $this->getResponseHeader($header);103 if (!$responseHeader) {104 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(105 'Failed asserting response header, header "%s" do not exists',106 $header107 ));108 }109 if ($match == $responseHeader->getFieldValue()) {110 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(111 'Failed asserting response header "%s" DOES NOT CONTAIN "%s"',112 $header,113 $match114 ));115 }116 $this->assertNotEquals($match, $responseHeader->getFieldValue());117 }118 /**119 * Assert response header exists and matches the given pattern120 *121 * @param string $header122 * @param string $pattern123 */124 public function assertResponseHeaderRegex($header, $pattern)125 {126 $responseHeader = $this->getResponseHeader($header);127 if (!$responseHeader) {128 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(129 'Failed asserting response header, header "%s" do not exists',130 $header131 ));132 }133 if (!preg_match($pattern, $responseHeader->getFieldValue())) {134 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(135 'Failed asserting response header "%s" exists and matches regex "%s", actual content is "%s"',136 $header,137 $pattern,138 $responseHeader->getFieldValue()139 ));140 }141 $this->assertTrue((bool) preg_match($pattern, $responseHeader->getFieldValue()));142 }143 /**144 * Assert response header does not exist and/or does not match the given regex145 *146 * @param string $header147 * @param string $pattern148 */149 public function assertNotResponseHeaderRegex($header, $pattern)150 {151 $responseHeader = $this->getResponseHeader($header);152 if (!$responseHeader) {153 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(154 'Failed asserting response header, header "%s" do not exists',155 $header156 ));157 }158 if (preg_match($pattern, $responseHeader->getFieldValue())) {159 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(160 'Failed asserting response header "%s" DOES NOT MATCH regex "%s"',161 $header,162 $pattern163 ));164 }165 $this->assertFalse((bool) preg_match($pattern, $responseHeader->getFieldValue()));166 }167 /**168 * Assert that response is a redirect169 */170 public function assertRedirect()171 {172 $responseHeader = $this->getResponseHeader('Location');173 if (false === $responseHeader) {174 throw new PHPUnit_Framework_ExpectationFailedException(175 'Failed asserting response is a redirect'176 );177 }178 $this->assertNotEquals(false, $responseHeader);179 }180 /**181 * Assert that response is NOT a redirect182 */183 public function assertNotRedirect()184 {185 $responseHeader = $this->getResponseHeader('Location');186 if (false !== $responseHeader) {187 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(188 'Failed asserting response is NOT a redirect, actual redirection is "%s"',189 $responseHeader->getFieldValue()190 ));191 }192 $this->assertFalse($responseHeader);193 }194 /**195 * Assert that response redirects to given URL196 *197 * @param string $url198 */199 public function assertRedirectTo($url)200 {201 $responseHeader = $this->getResponseHeader('Location');202 if (!$responseHeader) {203 throw new PHPUnit_Framework_ExpectationFailedException(204 'Failed asserting response is a redirect'205 );206 }207 if ($url != $responseHeader->getFieldValue()) {208 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(209 'Failed asserting response redirects to "%s", actual redirection is "%s"',210 $url,211 $responseHeader->getFieldValue()212 ));213 }214 $this->assertEquals($url, $responseHeader->getFieldValue());215 }216 /**217 * Assert that response does not redirect to given URL218 *219 * @param string $url220 */221 public function assertNotRedirectTo($url)222 {223 $responseHeader = $this->getResponseHeader('Location');224 if (!$responseHeader) {225 throw new PHPUnit_Framework_ExpectationFailedException(226 'Failed asserting response is a redirect'227 );228 }229 if ($url == $responseHeader->getFieldValue()) {230 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(231 'Failed asserting response redirects to "%s"',232 $url233 ));234 }235 $this->assertNotEquals($url, $responseHeader->getFieldValue());236 }237 /**238 * Assert that redirect location matches pattern239 *240 * @param string $pattern241 */242 public function assertRedirectRegex($pattern)243 {244 $responseHeader = $this->getResponseHeader('Location');245 if (!$responseHeader) {246 throw new PHPUnit_Framework_ExpectationFailedException(247 'Failed asserting response is a redirect'248 );249 }250 if (!preg_match($pattern, $responseHeader->getFieldValue())) {251 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(252 'Failed asserting response redirects to URL MATCHING "%s", actual redirection is "%s"',253 $pattern,254 $responseHeader->getFieldValue()255 ));256 }257 $this->assertTrue((bool) preg_match($pattern, $responseHeader->getFieldValue()));258 }259 /**260 * Assert that redirect location does not match pattern261 *262 * @param string $pattern263 */264 public function assertNotRedirectRegex($pattern)265 {266 $responseHeader = $this->getResponseHeader('Location');267 if (!$responseHeader) {268 throw new PHPUnit_Framework_ExpectationFailedException(269 'Failed asserting response is a redirect'270 );271 }272 if (preg_match($pattern, $responseHeader->getFieldValue())) {273 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(274 'Failed asserting response DOES NOT redirect to URL MATCHING "%s"',275 $pattern276 ));277 }278 $this->assertFalse((bool) preg_match($pattern, $responseHeader->getFieldValue()));279 }280 /**281 * Register XPath namespaces282 *283 * @param array $xpathNamespaces284 */285 public function registerXpathNamespaces(array $xpathNamespaces)286 {287 $this->xpathNamespaces = $xpathNamespaces;288 }289 /**290 * Execute a DOM/XPath query291 *292 * @param string $path293 * @param bool $useXpath294 * @return array295 */296 private function query($path, $useXpath = false)297 {298 $response = $this->getResponse();299 $dom = new Dom\Query($response->getContent());300 if ($useXpath) {301 $dom->registerXpathNamespaces($this->xpathNamespaces);302 return $dom->queryXpath($path);303 }304 return $dom->execute($path);305 }306 /**307 * Execute a xpath query308 *309 * @param string $path310 * @return array311 */312 private function xpathQuery($path)313 {314 return $this->query($path, true);315 }316 /**317 * Count the dom query executed318 *319 * @param string $path320 * @return int321 */322 private function queryCount($path)323 {324 return count($this->query($path, false));325 }326 /**327 * Count the dom query executed328 *329 * @param string $path330 * @return int331 */332 private function xpathQueryCount($path)333 {334 return count($this->xpathQuery($path));335 }336 /**337 * Assert against DOM/XPath selection338 *339 * @param string $path340 * @param bool $useXpath341 */342 private function queryAssertion($path, $useXpath = false)343 {344 $method = $useXpath ? 'xpathQueryCount' : 'queryCount';345 $match = $this->$method($path);346 if (!$match > 0) {347 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(348 'Failed asserting node DENOTED BY %s EXISTS',349 $path350 ));351 }352 $this->assertTrue($match > 0);353 }354 /**355 * Assert against DOM selection356 *357 * @param string $path CSS selector path358 */359 public function assertQuery($path)360 {361 $this->queryAssertion($path, false);362 }363 /**364 * Assert against XPath selection365 *366 * @param string $path XPath path367 */368 public function assertXpathQuery($path)369 {370 $this->queryAssertion($path, true);371 }372 /**373 * Assert against DOM/XPath selection374 *375 * @param string $path CSS selector path376 * @param bool $useXpath377 */378 private function notQueryAssertion($path, $useXpath = false)379 {380 $method = $useXpath ? 'xpathQueryCount' : 'queryCount';381 $match = $this->$method($path);382 if ($match != 0) {383 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(384 'Failed asserting node DENOTED BY %s DOES NOT EXIST',385 $path386 ));387 }388 $this->assertEquals(0, $match);389 }390 /**391 * Assert against DOM selection392 *393 * @param string $path CSS selector path394 */395 public function assertNotQuery($path)396 {397 $this->notQueryAssertion($path, false);398 }399 /**400 * Assert against XPath selection401 *402 * @param string $path XPath path403 */404 public function assertNotXpathQuery($path)405 {406 $this->notQueryAssertion($path, true);407 }408 /**409 * Assert against DOM/XPath selection; should contain exact number of nodes410 *411 * @param string $path CSS selector path412 * @param string $count Number of nodes that should match413 * @param bool $useXpath414 */415 private function queryCountAssertion($path, $count, $useXpath = false)416 {417 $method = $useXpath ? 'xpathQueryCount' : 'queryCount';418 $match = $this->$method($path);419 if ($match != $count) {420 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(421 'Failed asserting node DENOTED BY %s OCCURS EXACTLY %d times, actually occurs %d times',422 $path,423 $count,424 $match425 ));426 }427 $this->assertEquals($match, $count);428 }429 /**430 * Assert against DOM selection; should contain exact number of nodes431 *432 * @param string $path CSS selector path433 * @param string $count Number of nodes that should match434 */435 public function assertQueryCount($path, $count)436 {437 $this->queryCountAssertion($path, $count, false);438 }439 /**440 * Assert against XPath selection; should contain exact number of nodes441 *442 * @param string $path XPath path443 * @param string $count Number of nodes that should match444 */445 public function assertXpathQueryCount($path, $count)446 {447 $this->queryCountAssertion($path, $count, true);448 }449 /**450 * Assert against DOM/XPath selection; should NOT contain exact number of nodes451 *452 * @param string $path CSS selector path453 * @param string $count Number of nodes that should NOT match454 * @param bool $useXpath455 */456 private function notQueryCountAssertion($path, $count, $useXpath = false)457 {458 $method = $useXpath ? 'xpathQueryCount' : 'queryCount';459 $match = $this->$method($path);460 if ($match == $count) {461 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(462 'Failed asserting node DENOTED BY %s DOES NOT OCCUR EXACTLY %d times',463 $path,464 $count465 ));466 }467 $this->assertNotEquals($match, $count);468 }469 /**470 * Assert against DOM selection; should NOT contain exact number of nodes471 *472 * @param string $path CSS selector path473 * @param string $count Number of nodes that should NOT match474 */475 public function assertNotQueryCount($path, $count)476 {477 $this->notQueryCountAssertion($path, $count, false);478 }479 /**480 * Assert against XPath selection; should NOT contain exact number of nodes481 *482 * @param string $path XPath path483 * @param string $count Number of nodes that should NOT match484 */485 public function assertNotXpathQueryCount($path, $count)486 {487 $this->notQueryCountAssertion($path, $count, true);488 }489 /**490 * Assert against DOM/XPath selection; should contain at least this number of nodes491 *492 * @param string $path CSS selector path493 * @param string $count Minimum number of nodes that should match494 * @param bool $useXpath495 */496 private function queryCountMinAssertion($path, $count, $useXpath = false)497 {498 $method = $useXpath ? 'xpathQueryCount' : 'queryCount';499 $match = $this->$method($path);500 if ($match < $count) {501 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(502 'Failed asserting node DENOTED BY %s OCCURS AT LEAST %d times, actually occurs %d times',503 $path,504 $count,505 $match506 ));507 }508 $this->assertTrue($match >= $count);509 }510 /**511 * Assert against DOM selection; should contain at least this number of nodes512 *513 * @param string $path CSS selector path514 * @param string $count Minimum number of nodes that should match515 */516 public function assertQueryCountMin($path, $count)517 {518 $this->queryCountMinAssertion($path, $count, false);519 }520 /**521 * Assert against XPath selection; should contain at least this number of nodes522 *523 * @param string $path XPath path524 * @param string $count Minimum number of nodes that should match525 */526 public function assertXpathQueryCountMin($path, $count)527 {528 $this->queryCountMinAssertion($path, $count, true);529 }530 /**531 * Assert against DOM/XPath selection; should contain no more than this number of nodes532 *533 * @param string $path CSS selector path534 * @param string $count Maximum number of nodes that should match535 * @param bool $useXpath536 */537 private function queryCountMaxAssertion($path, $count, $useXpath = false)538 {539 $method = $useXpath ? 'xpathQueryCount' : 'queryCount';540 $match = $this->$method($path);541 if ($match > $count) {542 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(543 'Failed asserting node DENOTED BY %s OCCURS AT MOST %d times, actually occurs %d times',544 $path,545 $count,546 $match547 ));548 }549 $this->assertTrue($match <= $count);550 }551 /**552 * Assert against DOM selection; should contain no more than this number of nodes553 *554 * @param string $path CSS selector path555 * @param string $count Maximum number of nodes that should match556 */557 public function assertQueryCountMax($path, $count)558 {559 $this->queryCountMaxAssertion($path, $count, false);560 }561 /**562 * Assert against XPath selection; should contain no more than this number of nodes563 *564 * @param string $path XPath path565 * @param string $count Maximum number of nodes that should match566 */567 public function assertXpathQueryCountMax($path, $count)568 {569 $this->queryCountMaxAssertion($path, $count, true);570 }571 /**572 * Assert against DOM/XPath selection; node should contain content573 *574 * @param string $path CSS selector path575 * @param string $match content that should be contained in matched nodes576 * @param bool $useXpath577 */578 private function queryContentContainsAssertion($path, $match, $useXpath = false)579 {580 $result = $this->query($path, $useXpath);581 if ($result->count() == 0) {582 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(583 'Failed asserting node DENOTED BY %s EXISTS',584 $path585 ));586 }587 foreach ($result as $node) {588 if ($node->nodeValue == $match) {589 $this->assertEquals($match, $node->nodeValue);590 return;591 }592 }593 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(594 'Failed asserting node denoted by %s CONTAINS content "%s"',595 $path,596 $match597 ));598 }599 /**600 * Assert against DOM selection; node should contain content601 *602 * @param string $path CSS selector path603 * @param string $match content that should be contained in matched nodes604 */605 public function assertQueryContentContains($path, $match)606 {607 $this->queryContentContainsAssertion($path, $match, false);608 }609 /**610 * Assert against XPath selection; node should contain content611 *612 * @param string $path XPath path613 * @param string $match content that should be contained in matched nodes614 */615 public function assertXpathQueryContentContains($path, $match)616 {617 $this->queryContentContainsAssertion($path, $match, true);618 }619 /**620 * Assert against DOM/XPath selection; node should NOT contain content621 *622 * @param string $path CSS selector path623 * @param string $match content that should NOT be contained in matched nodes624 * @param bool $useXpath625 */626 private function notQueryContentContainsAssertion($path, $match, $useXpath = false)627 {628 $result = $this->query($path, $useXpath);629 if ($result->count() == 0) {630 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(631 'Failed asserting node DENOTED BY %s EXISTS',632 $path633 ));634 }635 foreach ($result as $node) {636 if ($node->nodeValue == $match) {637 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(638 'Failed asserting node DENOTED BY %s DOES NOT CONTAIN content "%s"',639 $path,640 $match641 ));642 }643 }644 $currentValue = $node->nodeValue;645 $this->assertNotEquals($currentValue, $match);646 }647 /**648 * Assert against DOM selection; node should NOT contain content649 *650 * @param string $path CSS selector path651 * @param string $match content that should NOT be contained in matched nodes652 */653 public function assertNotQueryContentContains($path, $match)654 {655 $this->notQueryContentContainsAssertion($path, $match, false);656 }657 /**658 * Assert against XPath selection; node should NOT contain content659 *660 * @param string $path XPath path661 * @param string $match content that should NOT be contained in matched nodes662 */663 public function assertNotXpathQueryContentContains($path, $match)664 {665 $this->notQueryContentContainsAssertion($path, $match, true);666 }667 /**668 * Assert against DOM/XPath selection; node should match content669 *670 * @param string $path CSS selector path671 * @param string $pattern Pattern that should be contained in matched nodes672 * @param bool $useXpath673 */674 private function queryContentRegexAssertion($path, $pattern, $useXpath = false)675 {676 $result = $this->query($path, $useXpath);677 if ($result->count() == 0) {678 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(679 'Failed asserting node DENOTED BY %s EXISTS',680 $path681 ));682 }683 if (!preg_match($pattern, $result->current()->nodeValue)) {684 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(685 'Failed asserting node denoted by %s CONTAINS content MATCHING "%s", actual content is "%s"',686 $path,687 $pattern,688 $result->current()->nodeValue689 ));690 }691 $this->assertTrue((bool) preg_match($pattern, $result->current()->nodeValue));692 }693 /**694 * Assert against DOM selection; node should match content695 *696 * @param string $path CSS selector path697 * @param string $pattern Pattern that should be contained in matched nodes698 */699 public function assertQueryContentRegex($path, $pattern)700 {701 $this->queryContentRegexAssertion($path, $pattern, false);702 }703 /**704 * Assert against XPath selection; node should match content705 *706 * @param string $path XPath path707 * @param string $pattern Pattern that should be contained in matched nodes708 */709 public function assertXpathQueryContentRegex($path, $pattern)710 {711 $this->queryContentRegexAssertion($path, $pattern, true);712 }713 /**714 * Assert against DOM/XPath selection; node should NOT match content715 *716 * @param string $path CSS selector path717 * @param string $pattern pattern that should NOT be contained in matched nodes718 * @param bool $useXpath719 */720 private function notQueryContentRegexAssertion($path, $pattern, $useXpath = false)721 {722 $result = $this->query($path, $useXpath);723 if ($result->count() == 0) {724 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(725 'Failed asserting node DENOTED BY %s EXISTS',726 $path727 ));728 }729 if (preg_match($pattern, $result->current()->nodeValue)) {730 throw new PHPUnit_Framework_ExpectationFailedException(sprintf(731 'Failed asserting node DENOTED BY %s DOES NOT CONTAIN content MATCHING "%s"',732 $path,733 $pattern734 ));735 }736 $this->assertFalse((bool) preg_match($pattern, $result->current()->nodeValue));737 }738 /**739 * Assert against DOM selection; node should NOT match content740 *741 * @param string $path CSS selector path742 * @param string $pattern pattern that should NOT be contained in matched nodes743 */744 public function assertNotQueryContentRegex($path, $pattern)745 {746 $this->notQueryContentRegexAssertion($path, $pattern, false);747 }748 /**749 * Assert against XPath selection; node should NOT match content750 *751 * @param string $path XPath path752 * @param string $pattern pattern that should NOT be contained in matched nodes753 */754 public function assertNotXpathQueryContentRegex($path, $pattern)755 {756 $this->notQueryContentRegexAssertion($path, $pattern, true);757 }758}...

Full Screen

Full Screen

SegmentExpression.php

Source:SegmentExpression.php Github

copy

Full Screen

...85 . self::MATCH_DOES_NOT_CONTAIN . '|'86 . preg_quote(self::MATCH_STARTS_WITH) . '|'87 . preg_quote(self::MATCH_ENDS_WITH)88 . '){1}(.*)/';89 $match = preg_match($pattern, $operand, $matches);90 if ($match == 0) {91 throw new Exception('The segment \'' . $operand . '\' is not valid.');92 }93 $leftMember = $matches[1];94 $operation = $matches[2];95 $valueRightMember = urldecode($matches[3]);96 // is null / is not null97 if ($valueRightMember === '') {98 if ($operation == self::MATCH_NOT_EQUAL) {99 $operation = self::MATCH_IS_NOT_NULL_NOR_EMPTY;100 } elseif ($operation == self::MATCH_EQUAL) {101 $operation = self::MATCH_IS_NULL_OR_EMPTY;102 } else {103 throw new Exception('The segment \'' . $operand . '\' has no value specified. You can leave this value empty ' .104 'only when you use the operators: ' . self::MATCH_NOT_EQUAL . ' (is not) or ' . self::MATCH_EQUAL . ' (is)');105 }106 }107 $parsedSubExpressions[] = array(108 self::INDEX_BOOL_OPERATOR => $operator,109 self::INDEX_OPERAND => array(110 self::INDEX_OPERAND_NAME => $leftMember,111 self::INDEX_OPERAND_OPERATOR => $operation,112 self::INDEX_OPERAND_VALUE => $valueRightMember,113 ));114 }115 $this->parsedSubExpressions = $parsedSubExpressions;116 return $parsedSubExpressions;117 }118 /**119 * Set the given expression120 * @param $parsedSubExpressions121 */122 public function setSubExpressionsAfterCleanup($parsedSubExpressions)123 {124 $this->parsedSubExpressions = $parsedSubExpressions;125 }126 /**127 * @param array $availableTables128 */129 public function parseSubExpressionsIntoSqlExpressions(&$availableTables = array())130 {131 $sqlSubExpressions = array();132 $this->valuesBind = array();133 $this->joins = array();134 foreach ($this->parsedSubExpressions as $leaf) {135 $operator = $leaf[self::INDEX_BOOL_OPERATOR];136 $operandDefinition = $leaf[self::INDEX_OPERAND];137 $operand = $this->getSqlMatchFromDefinition($operandDefinition, $availableTables);138 if ($operand[self::INDEX_OPERAND_OPERATOR] !== null) {139 if (is_array($operand[self::INDEX_OPERAND_OPERATOR])) {140 $this->valuesBind = array_merge($this->valuesBind, $operand[self::INDEX_OPERAND_OPERATOR]);141 } else {142 $this->valuesBind[] = $operand[self::INDEX_OPERAND_OPERATOR];143 }144 }145 $operand = $operand[self::INDEX_OPERAND_NAME];146 $sqlSubExpressions[] = array(147 self::INDEX_BOOL_OPERATOR => $operator,148 self::INDEX_OPERAND => $operand,149 );150 }151 $this->tree = $sqlSubExpressions;152 }153 /**154 * Given an array representing one filter operand ( left member , operation , right member)155 * Will return an array containing156 * - the SQL substring,157 * - the values to bind to this substring158 *159 * @param array $def160 * @param array $availableTables161 * @throws Exception162 * @return array163 */164 protected function getSqlMatchFromDefinition($def, &$availableTables)165 {166 $field = $def[0];167 $matchType = $def[1];168 $value = $def[2];169 // Segment::getCleanedExpression() may return array(null, $matchType, null)170 $operandWillNotMatchAnyRow = empty($field) && is_null($value);171 if($operandWillNotMatchAnyRow) {172 if($matchType == self::MATCH_EQUAL) {173 // eg. pageUrl==DoesNotExist174 // Equal to NULL means it will match none175 $sqlExpression = self::SQL_WHERE_DO_NOT_MATCH_ANY_ROW;176 } elseif($matchType == self::MATCH_NOT_EQUAL) {177 // eg. pageUrl!=DoesNotExist178 // Not equal to NULL means it matches all rows179 $sqlExpression = self::SQL_WHERE_MATCHES_ALL_ROWS;180 } elseif($matchType == self::MATCH_CONTAINS181 || $matchType == self::MATCH_DOES_NOT_CONTAIN182 || $matchType == self::MATCH_STARTS_WITH183 || $matchType == self::MATCH_ENDS_WITH) {184 // no action was found for CONTAINS / DOES NOT CONTAIN185 // eg. pageUrl=@DoesNotExist -> matches no row186 // eg. pageUrl!@DoesNotExist -> matches no rows187 $sqlExpression = self::SQL_WHERE_DO_NOT_MATCH_ANY_ROW;188 } else {189 // it is not expected to reach this code path190 throw new Exception("Unexpected match type $matchType for your segment. " .191 "Please report this issue to the Piwik team with the segment you are using.");192 }193 return array($sqlExpression, $value = null);194 }195 $alsoMatchNULLValues = false;196 switch ($matchType) {197 case self::MATCH_EQUAL:198 $sqlMatch = '%s =';199 break;200 case self::MATCH_NOT_EQUAL:201 $sqlMatch = '%s <>';202 $alsoMatchNULLValues = true;203 break;204 case self::MATCH_GREATER:205 $sqlMatch = '%s >';206 break;207 case self::MATCH_LESS:208 $sqlMatch = '%s <';209 break;210 case self::MATCH_GREATER_OR_EQUAL:211 $sqlMatch = '%s >=';212 break;213 case self::MATCH_LESS_OR_EQUAL:214 $sqlMatch = '%s <=';215 break;216 case self::MATCH_CONTAINS:217 $sqlMatch = '%s LIKE';218 $value = '%' . $this->escapeLikeString($value) . '%';219 break;220 case self::MATCH_DOES_NOT_CONTAIN:221 $sqlMatch = '%s NOT LIKE';222 $value = '%' . $this->escapeLikeString($value) . '%';223 $alsoMatchNULLValues = true;224 break;225 case self::MATCH_STARTS_WITH:226 $sqlMatch = '%s LIKE';227 $value = $this->escapeLikeString($value) . '%';228 break;229 case self::MATCH_ENDS_WITH:230 $sqlMatch = '%s LIKE';231 $value = '%' . $this->escapeLikeString($value);232 break;233 case self::MATCH_IS_NOT_NULL_NOR_EMPTY:234 $sqlMatch = '%s IS NOT NULL AND (%s <> \'\' OR %s = 0)';235 $value = null;236 break;237 case self::MATCH_IS_NULL_OR_EMPTY:238 $sqlMatch = '%s IS NULL OR %s = \'\' ';239 $value = null;240 break;241 case self::MATCH_ACTIONS_CONTAINS:242 // this match type is not accessible from the outside243 // (it won't be matched in self::parseSubExpressions())244 // it can be used internally to inject sub-expressions into the query.245 // see Segment::getCleanedExpression()246 $sqlMatch = '%s IN (' . $value['SQL'] . ')';247 $value = $value['bind'];248 break;249 default:250 throw new Exception("Filter contains the match type '" . $matchType . "' which is not supported");251 break;252 }253 // We match NULL values when rows are excluded only when we are not doing a254 $alsoMatchNULLValues = $alsoMatchNULLValues && !empty($value);255 $sqlMatch = str_replace('%s', $field, $sqlMatch);256 if ($matchType === self::MATCH_ACTIONS_CONTAINS257 || is_null($value)258 ) {259 $sqlExpression = "( $sqlMatch )";260 } else {261 if ($alsoMatchNULLValues) {262 $sqlExpression = "( $field IS NULL OR $sqlMatch ? )";263 } else {264 $sqlExpression = "$sqlMatch ?";265 }266 }267 $this->checkFieldIsAvailable($field, $availableTables);268 return array($sqlExpression, $value);269 }270 /**...

Full Screen

Full Screen

IsArrayTest.php

Source:IsArrayTest.php Github

copy

Full Screen

...11 {12 $this->assertMatches(13 anArray(array(equalTo('a'), equalTo('b'), equalTo('c'))),14 array('a', 'b', 'c'),15 'should match array with matching elements'16 );17 }18 public function testDoesNotMatchAnArrayWhenElementsDoNotMatch()19 {20 $this->assertDoesNotMatch(21 anArray(array(equalTo('a'), equalTo('b'))),22 array('b', 'c'),23 'should not match array with different elements'24 );25 }26 public function testDoesNotMatchAnArrayOfDifferentSize()27 {28 $this->assertDoesNotMatch(29 anArray(array(equalTo('a'), equalTo('b'))),30 array('a', 'b', 'c'),31 'should not match larger array'32 );33 $this->assertDoesNotMatch(34 anArray(array(equalTo('a'), equalTo('b'))),35 array('a'),36 'should not match smaller array'37 );38 }39 public function testDoesNotMatchNull()40 {41 $this->assertDoesNotMatch(42 anArray(array(equalTo('a'))),43 null,44 'should not match null'45 );46 }47 public function testHasAReadableDescription()48 {49 $this->assertDescription(50 '["a", "b"]',51 anArray(array(equalTo('a'), equalTo('b')))52 );53 }54 public function testHasAReadableMismatchDescriptionWhenKeysDontMatch()55 {56 $this->assertMismatchDescription(57 'array keys were [<1>, <2>]',58 anArray(array(equalTo('a'), equalTo('b'))),59 array(1 => 'a', 2 => 'b')60 );61 }62 public function testSupportsMatchesAssociativeArrays()63 {64 $this->assertMatches(65 anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'), 'z'=>equalTo('c'))),66 array('x'=>'a', 'y'=>'b', 'z'=>'c'),67 'should match associative array with matching elements'68 );69 }70 public function testDoesNotMatchAnAssociativeArrayWhenKeysDoNotMatch()71 {72 $this->assertDoesNotMatch(73 anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'))),74 array('x'=>'b', 'z'=>'c'),75 'should not match array with different keys'76 );77 }78}...

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1$not = new Not();2$not->match('1.php');3$not = new Not();4$not->match('2.php');5$not = new Not();6$not->match('3.php');7$not = new Not();8$not->match('4.php');9$not = new Not();10$not->match('5.php');11$not = new Not();12$not->match('6.php');13$not = new Not();14$not->match('7.php');15$not = new Not();16$not->match('8.php');17$not = new Not();18$not->match('9.php');19$not = new Not();20$not->match('10.php');21$not = new Not();22$not->match('11.php');23$not = new Not();24$not->match('12.php');25$not = new Not();26$not->match('13.php');27$not = new Not();28$not->match('14.php');29$not = new Not();30$not->match('15.php');31$not = new Not();32$not->match('16.php');

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1$not = new Not();2$not->match('/1.php');3$not = new Not();4$not->match('/2.php');5$not = new Not();6$not->match('/3.php');

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1$not = new Not();2$not->match('hello');3$not = new Not();4$not->match('world');5$not = new Not();6$not->match('hello');7$not = new Not();8$not->match('world');9$not = new Not();10$not->match('hello');11$not = new Not();12$not->match('world');13$not = new Not();14$not->match('hello');15$not = new Not();16$not->match('world');17$not = new Not();18$not->match('hello');19$not = new Not();20$not->match('world');21$not = new Not();22$not->match('hello');23$not = new Not();24$not->match('world');25$not = new Not();26$not->match('hello');27$not = new Not();28$not->match('world');29$not = new Not();30$not->match('hello');31$not = new Not();32$not->match('world');33$not = new Not();34$not->match('hello');

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1$not = new Not(new Match('test'));2var_dump($not->match('test'));3$not = new Not(new Match('test'));4var_dump($not->match('test'));5$not = new Not(new Match('test'));6var_dump($not->match('test'));7$not = new Not(new Match('test'));8var_dump($not->match('test'));9$not = new Not(new Match('test'));10var_dump($not->match('test'));11$not = new Not(new Match('test'));12var_dump($not->match('test'));13$not = new Not(new Match('test'));14var_dump($not->match('test'));15$not = new Not(new Match('test'));16var_dump($not->match('test'));17$not = new Not(new Match('test'));18var_dump($not->match('test'));19$not = new Not(new Match('test'));20var_dump($not->match('test'));21$not = new Not(new Match('test'));22var_dump($not->match('test'));23$not = new Not(new Match('test'));24var_dump($not->match('test'));25$not = new Not(new Match('test'));26var_dump($not->match('test'));27$not = new Not(new Match('test'));28var_dump($not->match('test'));

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1$not = new Not();2$not->match($data, $rule);3$not = new Not();4$not->match($data, $rule);5$not = new Not();6$not->match($data, $rule);

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1$not = new Not();2$not->match('1.php');3$not = new Not();4$not->match('2.php');5$not = new Not();6$not->match('3.php');7$not = new Not();8$not->match('4.php');9$not = new Not();10$not->match('5.php');11$not = new Not();12$not->match('6.php');13$not = new Not();14$not->match('7.php');15$not = new Not();16$not->match('8.php');17$not = new Not();18$not->match('9.php');19$not = new Not();20$not->match('10.php');21$not = new Not();22$not->match('11.php');23$not = new Not();24$not->match('12.php');25$not = new Not();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockery automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Not

Trigger match code on LambdaTest Cloud Grid

Execute automation tests with match on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful