Skip to content

Commit

Permalink
pint
Browse files Browse the repository at this point in the history
  • Loading branch information
markhuot committed Dec 22, 2023
1 parent a417aee commit 8913c77
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 44 deletions.
16 changes: 8 additions & 8 deletions src/behaviors/TestableResponseBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace markhuot\craftpest\behaviors;

use Illuminate\Support\Arr;
use markhuot\craftpest\illuminate\Assert as PHPUnit;
use markhuot\craftpest\dom\Form;
use markhuot\craftpest\dom\NodeList;
use markhuot\craftpest\http\RequestBuilder;
use markhuot\craftpest\http\requests\WebRequest;
use markhuot\craftpest\illuminate\Assert as PHPUnit;
use markhuot\craftpest\illuminate\AssertableJsonString;
use markhuot\craftpest\test\Benchmark;
use markhuot\craftpest\web\TestableResponse;
Expand Down Expand Up @@ -476,13 +476,13 @@ public function assertJson(array|callable $value, $strict = false)
$json->assertSubset($value, $strict);
} else {
PHPUnit::fail('Not implemented');
// $assert = AssertableJson::fromAssertableJsonString($json);
//
// $value($assert);
//
// if (Arr::isAssoc($assert->toArray())) {
// $assert->interacted();
// }
// $assert = AssertableJson::fromAssertableJsonString($json);
//
// $value($assert);
//
// if (Arr::isAssoc($assert->toArray())) {
// $assert->interacted();
// }
}

return $this->response;
Expand Down
10 changes: 0 additions & 10 deletions src/illuminate/ArraySubset.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ final class ArraySubset extends Constraint
/**
* Create a new array subset constraint instance.
*
* @param iterable $subset
* @param bool $strict
* @return void
*/
public function __construct(iterable $subset, bool $strict = false)
Expand All @@ -46,9 +44,6 @@ public function __construct(iterable $subset, bool $strict = false)
* failure.
*
* @param mixed $other
* @param string $description
* @param bool $returnResult
* @return bool|null
*
* @throws \PHPUnit\Framework\ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
Expand Down Expand Up @@ -89,7 +84,6 @@ public function evaluate($other, string $description = '', bool $returnResult =
/**
* Returns a string representation of the constraint.
*
* @return string
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
Expand All @@ -105,7 +99,6 @@ public function toString(): string
* cases. This method should return the second part of that sentence.
*
* @param mixed $other
* @return string
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
Expand All @@ -119,9 +112,6 @@ protected function failureDescription($other): string
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param iterable $other
* @return array
*/
private function toArray(iterable $other): array
{
Expand Down
11 changes: 4 additions & 7 deletions src/illuminate/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ abstract class Assert extends PHPUnit
/**
* Asserts that an array has a specified subset.
*
* @param \ArrayAccess|array $subset
* @param \ArrayAccess|array $array
* @param bool $checkForIdentity
* @param string $msg
* @return void
* @param \ArrayAccess|array $subset
* @param \ArrayAccess|array $array
*/
public static function assertArraySubset($subset, $array, bool $checkForIdentity = false, string $msg = ''): void
{
if (!(is_array($subset) || $subset instanceof ArrayAccess)) {
if (! (is_array($subset) || $subset instanceof ArrayAccess)) {
throw InvalidArgumentException::create(1, 'array or ArrayAccess');
}

if (!(is_array($array) || $array instanceof ArrayAccess)) {
if (! (is_array($array) || $array instanceof ArrayAccess)) {
throw InvalidArgumentException::create(2, 'array or ArrayAccess');
}

Expand Down
18 changes: 1 addition & 17 deletions src/illuminate/AssertableJsonString.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use markhuot\craftpest\illuminate\Assert as PHPUnit;
use JsonSerializable;
use markhuot\craftpest\illuminate\Assert as PHPUnit;

class AssertableJsonString implements ArrayAccess, Countable
{
Expand Down Expand Up @@ -62,7 +62,6 @@ public function json($key = null)
/**
* Assert that the response JSON has the expected count of items at the given key.
*
* @param int $count
* @param string|null $key
* @return $this
*/
Expand All @@ -88,7 +87,6 @@ public function assertCount(int $count, $key = null)
/**
* Assert that the response has the exact given JSON.
*
* @param array $data
* @return $this
*/
public function assertExact(array $data)
Expand All @@ -108,7 +106,6 @@ public function assertExact(array $data)
/**
* Assert that the response has the similar JSON as given.
*
* @param array $data
* @return $this
*/
public function assertSimilar(array $data)
Expand All @@ -126,7 +123,6 @@ public function assertSimilar(array $data)
/**
* Assert that the response contains the given JSON fragment.
*
* @param array $data
* @return $this
*/
public function assertFragment(array $data)
Expand Down Expand Up @@ -154,7 +150,6 @@ public function assertFragment(array $data)
/**
* Assert that the response does not contain the given JSON fragment.
*
* @param array $data
* @param bool $exact
* @return $this
*/
Expand Down Expand Up @@ -187,7 +182,6 @@ public function assertMissing(array $data, $exact = false)
/**
* Assert that the response does not contain the exact JSON fragment.
*
* @param array $data
* @return $this
*/
public function assertMissingExact(array $data)
Expand Down Expand Up @@ -249,7 +243,6 @@ public function assertPath($path, $expect)
/**
* Assert that the response has a given JSON structure.
*
* @param array|null $structure
* @param array|null $responseData
* @return $this
*/
Expand Down Expand Up @@ -285,7 +278,6 @@ public function assertStructure(array $structure = null, $responseData = null)
/**
* Assert that the response is a superset of the given JSON.
*
* @param array $data
* @param bool $strict
* @return $this
*/
Expand All @@ -301,7 +293,6 @@ public function assertSubset(array $data, $strict = false)
/**
* Reorder associative array keys to make it easy to compare arrays.
*
* @param array $data
* @return array
*/
protected function reorderAssocKeys(array $data)
Expand All @@ -321,7 +312,6 @@ protected function reorderAssocKeys(array $data)
/**
* Get the assertion message for assertJson.
*
* @param array $data
* @return string
*/
protected function assertJsonMessage(array $data)
Expand Down Expand Up @@ -356,8 +346,6 @@ protected function jsonSearchStrings($key, $value)

/**
* Get the total number of items in the underlying JSON array.
*
* @return int
*/
public function count(): int
{
Expand All @@ -368,7 +356,6 @@ public function count(): int
* Determine whether an offset exists.
*
* @param mixed $offset
* @return bool
*/
public function offsetExists($offset): bool
{
Expand All @@ -379,7 +366,6 @@ public function offsetExists($offset): bool
* Get the value at the given offset.
*
* @param string $offset
* @return mixed
*/
public function offsetGet($offset): mixed
{
Expand All @@ -391,7 +377,6 @@ public function offsetGet($offset): mixed
*
* @param string $offset
* @param mixed $value
* @return void
*/
public function offsetSet($offset, $value): void
{
Expand All @@ -402,7 +387,6 @@ public function offsetSet($offset, $value): void
* Unset the value at the given offset.
*
* @param string $offset
* @return void
*/
public function offsetUnset($offset): void
{
Expand Down
2 changes: 0 additions & 2 deletions src/illuminate/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class InvalidArgumentException extends Exception
{
/**
* Creates a new exception for an invalid argument.
*
* @return static
*/
public static function create(int $argument, string $type): static
{
Expand Down

0 comments on commit 8913c77

Please sign in to comment.