✏️ 编辑:BodyMatcher.php
路径:
/home/forge/woocommerce-square/vendor/apimatic/core/src/TestCase/BodyMatchers/BodyMatcher.php
大小:1.2 KB · 修改:2025-12-23 20:26:26 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php declare(strict_types=1); namespace Core\TestCase\BodyMatchers; use PHPUnit\Framework\TestCase; class BodyMatcher { protected $expectedBody; protected $bodyComparator; protected $defaultMessage = ''; /** * @var TestCase */ public $testCase; public $result; public $shouldAssert = true; /** * Initializes a new BodyMatcher with the parameters provided. */ public function __construct(BodyComparator $bodyComparator, $expectedBody = null) { $this->bodyComparator = $bodyComparator; $this->expectedBody = $expectedBody; } /** * Returns already set default message. */ public function getDefaultMessage(): string { return $this->defaultMessage; } /** * Sets testCase and result to the ones provided. */ public function set(TestCase $testCase, $result) { $this->testCase = $testCase; $this->result = $result; } /** * Asserts if the testCase results to true or not. */ public function assert(string $rawBody) { if ($this->shouldAssert) { $this->testCase->assertNotNull($this->result, 'Result does not exist'); } } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF