✏️ 编辑:NativeBodyMatcher.php
路径:
/home/forge/woocommerce-square/vendor/apimatic/core/src/TestCase/BodyMatchers/NativeBodyMatcher.php
大小:1.6 KB · 修改:2025-12-23 20:26:26 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php declare(strict_types=1); namespace Core\TestCase\BodyMatchers; class NativeBodyMatcher extends BodyMatcher { /** * Initializes a new NativeBodyMatcher object with the parameters provided. */ public static function init($expectedBody, bool $matchArrayOrder = false, bool $matchArrayCount = false): self { $matcher = new self(new BodyComparator(!$matchArrayCount, $matchArrayOrder, true, true), $expectedBody); if (is_scalar($expectedBody)) { $matcher->defaultMessage = 'Response values does not match'; return $matcher; } $type = getType($expectedBody); $strategy = self::getMatchingStrategy($matchArrayOrder, $matchArrayCount); $matcher->defaultMessage = "Response $type values does not match$strategy"; return $matcher; } private static function getMatchingStrategy(bool $matchArrayOrder, bool $matchArrayCount): string { if (!$matchArrayOrder) { if (!$matchArrayCount) { return ''; } return ' in size'; } if (!$matchArrayCount) { return ' in order'; } return ' in order or size'; } /** * Asserts if rawBody matches the criteria set within NativeBodyMatcher while initialization, * and if expectedBody is a subset of rawBody. */ public function assert(string $rawBody) { parent::assert($rawBody); $this->testCase->assertTrue( $this->bodyComparator->compare($this->expectedBody, $this->result), $this->defaultMessage ); } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF