|
3 | 3 | use Illuminate\Database\Eloquent\Factories\HasFactory;
|
4 | 4 | use Illuminate\Database\Eloquent\Model;
|
5 | 5 | use Illuminate\Foundation\Auth\User;
|
6 |
| -use Maize\Helpers\Tests\Models\Article; |
| 6 | +use Maize\Helpers\Tests\Support\Models\Article; |
7 | 7 |
|
8 | 8 | use function PHPUnit\Framework\assertNotEquals;
|
9 | 9 |
|
|
102 | 102 |
|
103 | 103 | ]);
|
104 | 104 |
|
| 105 | +it('pipe', function ($passable, $pipes, $result) { |
| 106 | + expect(hlp()->pipe($passable, $pipes))->toBe($result); |
| 107 | +})->with([ |
| 108 | + ['passable' => null, 'pipes' => [], 'result' => null], |
| 109 | + ['passable' => [], 'pipes' => [], 'result' => []], |
| 110 | + ['passable' => '', 'pipes' => [], 'result' => ''], |
| 111 | + ['passable' => 'test', 'pipes' => [], 'result' => 'test'], |
| 112 | + ['passable' => 'test', 'pipes' => [ |
| 113 | + \Maize\Helpers\Tests\Support\Actions\Uppercase::class, |
| 114 | + \Maize\Helpers\Tests\Support\Actions\Reverse::class, |
| 115 | + ], 'result' => 'TSET'], |
| 116 | + ['passable' => 'test', 'pipes' => [ |
| 117 | + \Maize\Helpers\Tests\Support\Actions\Reverse::class, |
| 118 | + \Maize\Helpers\Tests\Support\Actions\Uppercase::class, |
| 119 | + ], 'result' => 'TSET'], |
| 120 | + ['passable' => 'test', 'pipes' => [ |
| 121 | + \Maize\Helpers\Tests\Support\Actions\Uppercase::class, |
| 122 | + ], 'result' => 'TEST'], |
| 123 | + ['passable' => 'test', 'pipes' => [ |
| 124 | + \Maize\Helpers\Tests\Support\Actions\Reverse::class, |
| 125 | + ], 'result' => 'tset'], |
| 126 | +]); |
| 127 | + |
| 128 | +it('sanitizeString', function (?string $string, $result) { |
| 129 | + expect(hlp()->sanitizeString($string))->toBe($result); |
| 130 | +})->with([ |
| 131 | + ['string' => null, 'result' => null], |
| 132 | + ['string' => '', 'result' => ''], |
| 133 | + ['string' => ' test ', 'result' => 'test'], |
| 134 | + ['string' => '<h1> test </h1>', 'result' => 'test'], |
| 135 | + ['string' => ' <h1> test </h1> ', 'result' => 'test'], |
| 136 | + ['string' => ' test </h1> ', 'result' => 'test'], |
| 137 | + ['string' => ' <h1> test ', 'result' => 'test'], |
| 138 | + ['string' => 'test<br>', 'result' => 'test'], |
| 139 | + ['string' => 'test<br />', 'result' => 'test'], |
| 140 | + ['string' => '<h1></h1>', 'result' => ''], |
| 141 | + ['string' => '<br />', 'result' => ''], |
| 142 | +]); |
| 143 | + |
| 144 | +it('sanitizeArrayOfStrings', function (?array $array, $result) { |
| 145 | + expect(hlp()->sanitizeArrayOfStrings($array))->toBe($result); |
| 146 | +})->with([ |
| 147 | + ['array' => null, 'result' => null], |
| 148 | + ['array' => [], 'result' => []], |
| 149 | + ['array' => [null], 'result' => []], |
| 150 | + ['array' => ['a' => ''], 'result' => []], |
| 151 | + ['array' => ['a' => null], 'result' => []], |
| 152 | + ['array' => [' test ', ' test '], 'result' => ['test', 'test']], |
| 153 | + ['array' => ['a' => ' test ', 'b' => ' test '],'result' => ['a' => 'test', 'b' => 'test']], |
| 154 | + ['array' => ['a' => '<h1> test </h1>', 'b' => '<h1> test </h1>'],'result' => ['a' => 'test', 'b' => 'test']], |
| 155 | + ['array' => ['a' => ' <h1> test </h1> ', 'b' => ' <h1> test </h1> '],'result' => ['a' => 'test', 'b' => 'test']], |
| 156 | + ['array' => ['a' => ' test </h1> ', 'b' => ' test </h1> '],'result' => ['a' => 'test', 'b' => 'test']], |
| 157 | + ['array' => [' test </h1> ', ' test </h1> '], 'result' => ['test', 'test']], |
| 158 | + ['array' => [' <h1> test ', ' <h1> test '], 'result' => ['test', 'test']], |
| 159 | + ['array' => ['test<br>', 'test<br>'], 'result' => ['test', 'test']], |
| 160 | + ['array' => ['test<br />', 'test<br />'], 'result' => ['test', 'test']], |
| 161 | + ['array' => ['<h1></h1>', '<h1></h1>'], 'result' => []], |
| 162 | + ['array' => ['<br />', '<br />'], 'result' => []], |
| 163 | +]); |
| 164 | + |
105 | 165 | it('sanitizeUrl', function (?string $url, $result) {
|
106 | 166 | expect(hlp()->sanitizeUrl($url))->toBe($result);
|
107 | 167 | })->with([
|
|
0 commit comments