Skip to content

Commit

Permalink
Merge pull request #6 from TheDragonCode/1.x
Browse files Browse the repository at this point in the history
Fixed Str::of(): Argument #1 ($value) must be of type ?string, int given
  • Loading branch information
andrey-helldar authored Feb 20, 2023
2 parents f469c5d + 759e887 commit 9de9797
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 200 deletions.
4 changes: 2 additions & 2 deletions src/Services/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class Str
{
public static function of(?string $value): Stringable
public static function of(mixed $value): Stringable
{
return DS::of($value);
return DS::of((string) $value);
}

public static function pad(int $length, string $pad = 'x'): string
Expand Down
72 changes: 6 additions & 66 deletions tests/Sorters/FullGroupsOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,6 @@

class FullGroupsOrderTest extends TestCase
{
private array $values = [
100 => 'XXL',
101 => '26',
102 => '28',
103 => 'XL',
104 => 'ONE SIZE',
105 => 'XXS',
106 => '2',
107 => '54',
108 => 'XS',
109 => 'S',
110 => 'M',
111 => 'L',
112 => 'L/XL',
113 => 'XL/2XL',
114 => 'XS/S',
115 => 'M/L',
116 => '80B',
117 => '75C',
118 => '70B',
119 => '75A',
120 => '75B',
121 => '36',
122 => 'XXS-XS',
123 => '37',
124 => '38',
125 => '39',
126 => '40',
127 => 'S/M',
128 => '40х38х19 см',
129 => '70C',
130 => '44-46',
131 => 'some',
132 => '1',
133 => '30',
134 => '32',
135 => '34',
136 => '44/46',
137 => 'XXS/XS',
138 => 'XXS',
139 => '52-56',
140 => '102-104',
141 => '102-106',
142 => '102/106',
143 => '106',
145 => '110-112',
144 => '110-114',
146 => '90/94',
147 => '94-98',
148 => '98-102',
149 => '21',
150 => '3',
151 => '40х38х19 sm',
152 => '40х37х19 см',
153 => '40х37х20 см',
154 => '40х38х15 см',
155 => '41х38х15 см',
156 => '39х38х15 см',
];

private array $expected = [
// 3
118 => '70B',
Expand All @@ -94,14 +34,14 @@ class FullGroupsOrderTest extends TestCase
106 => '2',
150 => '3',
149 => '21',
101 => '26',
102 => '28',
101 => 26,
102 => 28,
133 => '30',
134 => '32',
135 => '34',
121 => '36',
123 => '37',
124 => '38',
123 => 37,
124 => 38,
125 => '39',
126 => '40',
130 => '44-46',
Expand Down Expand Up @@ -153,7 +93,7 @@ public function testArray(): void

public function testObjects(): void
{
$items = collect($this->values)->map(fn (string $value, int $key) => (object) [
$items = collect($this->values)->map(fn (mixed $value, int $key) => (object) [
'id' => $key,
'value' => $value,
'active' => true,
Expand All @@ -167,7 +107,7 @@ public function testObjects(): void

public function testCustomColumn(): void
{
$items = collect($this->values)->map(fn (string $value, int $key) => (object) [
$items = collect($this->values)->map(fn (mixed $value, int $key) => (object) [
'id' => $key,
'some' => $value,
]);
Expand Down
72 changes: 6 additions & 66 deletions tests/Sorters/PartialGroupsOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,6 @@

class PartialGroupsOrderTest extends TestCase
{
private array $values = [
100 => 'XXL',
101 => '26',
102 => '28',
103 => 'XL',
104 => 'ONE SIZE',
105 => 'XXS',
106 => '2',
107 => '54',
108 => 'XS',
109 => 'S',
110 => 'M',
111 => 'L',
112 => 'L/XL',
113 => 'XL/2XL',
114 => 'XS/S',
115 => 'M/L',
116 => '80B',
117 => '75C',
118 => '70B',
119 => '75A',
120 => '75B',
121 => '36',
122 => 'XXS-XS',
123 => '37',
124 => '38',
125 => '39',
126 => '40',
127 => 'S/M',
128 => '40х38х19 см',
129 => '70C',
130 => '44-46',
131 => 'some',
132 => '1',
133 => '30',
134 => '32',
135 => '34',
136 => '44/46',
137 => 'XXS/XS',
138 => 'XXS',
139 => '52-56',
140 => '102-104',
141 => '102-106',
142 => '102/106',
143 => '106',
145 => '110-112',
144 => '110-114',
146 => '90/94',
147 => '94-98',
148 => '98-102',
149 => '21',
150 => '3',
151 => '40х38х19 sm',
152 => '40х37х19 см',
153 => '40х37х20 см',
154 => '40х38х15 см',
155 => '41х38х15 см',
156 => '39х38х15 см',
];

private array $expected = [
// 3
118 => '70B',
Expand Down Expand Up @@ -102,14 +42,14 @@ class PartialGroupsOrderTest extends TestCase
106 => '2',
150 => '3',
149 => '21',
101 => '26',
102 => '28',
101 => 26,
102 => 28,
133 => '30',
134 => '32',
135 => '34',
121 => '36',
123 => '37',
124 => '38',
123 => 37,
124 => 38,
125 => '39',
126 => '40',
130 => '44-46',
Expand Down Expand Up @@ -150,7 +90,7 @@ public function testArray(): void

public function testObjects(): void
{
$items = collect($this->values)->map(fn (string $value, int $key) => (object) [
$items = collect($this->values)->map(fn (mixed $value, int $key) => (object) [
'id' => $key,
'value' => $value,
'active' => true,
Expand All @@ -164,7 +104,7 @@ public function testObjects(): void

public function testCustomColumn(): void
{
$items = collect($this->values)->map(fn (string $value, int $key) => (object) [
$items = collect($this->values)->map(fn (mixed $value, int $key) => (object) [
'id' => $key,
'some' => $value,
]);
Expand Down
72 changes: 6 additions & 66 deletions tests/Sorters/SorterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,6 @@

class SorterTest extends TestCase
{
private array $values = [
100 => 'XXL',
101 => '26',
102 => '28',
103 => 'XL',
104 => 'ONE SIZE',
105 => 'XXS',
106 => '2',
107 => '54',
108 => 'XS',
109 => 'S',
110 => 'M',
111 => 'L',
112 => 'L/XL',
113 => 'XL/2XL',
114 => 'XS/S',
115 => 'M/L',
116 => '80B',
117 => '75C',
118 => '70B',
119 => '75A',
120 => '75B',
121 => '36',
122 => 'XXS-XS',
123 => '37',
124 => '38',
125 => '39',
126 => '40',
127 => 'S/M',
128 => '40х38х19 см',
129 => '70C',
130 => '44-46',
131 => 'some',
132 => '1',
133 => '30',
134 => '32',
135 => '34',
136 => '44/46',
137 => 'XXS/XS',
138 => 'XXS',
139 => '52-56',
140 => '102-104',
141 => '102-106',
142 => '102/106',
143 => '106',
145 => '110-112',
144 => '110-114',
146 => '90/94',
147 => '94-98',
148 => '98-102',
149 => '21',
150 => '3',
151 => '40х38х19 sm',
152 => '40х37х19 см',
153 => '40х37х20 см',
154 => '40х38х15 см',
155 => '41х38х15 см',
156 => '39х38х15 см',
];

private array $expected = [
// 1
105 => 'XXS',
Expand All @@ -91,14 +31,14 @@ class SorterTest extends TestCase
106 => '2',
150 => '3',
149 => '21',
101 => '26',
102 => '28',
101 => 26,
102 => 28,
133 => '30',
134 => '32',
135 => '34',
121 => '36',
123 => '37',
124 => '38',
123 => 37,
124 => 38,
125 => '39',
126 => '40',
130 => '44-46',
Expand Down Expand Up @@ -144,7 +84,7 @@ public function testArray(): void

public function testObjects(): void
{
$items = collect($this->values)->map(fn (string $value, int $key) => (object) [
$items = collect($this->values)->map(fn (mixed $value, int $key) => (object) [
'id' => $key,
'value' => $value,
'active' => true,
Expand All @@ -158,7 +98,7 @@ public function testObjects(): void

public function testCustomColumn(): void
{
$items = collect($this->values)->map(fn (string $value, int $key) => (object) [
$items = collect($this->values)->map(fn (mixed $value, int $key) => (object) [
'id' => $key,
'some' => $value,
]);
Expand Down
59 changes: 59 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,63 @@

abstract class TestCase extends BaseTestCase
{
protected array $values = [
100 => 'XXL',
101 => 26,
102 => 28,
103 => 'XL',
104 => 'ONE SIZE',
105 => 'XXS',
106 => '2',
107 => '54',
108 => 'XS',
109 => 'S',
110 => 'M',
111 => 'L',
112 => 'L/XL',
113 => 'XL/2XL',
114 => 'XS/S',
115 => 'M/L',
116 => '80B',
117 => '75C',
118 => '70B',
119 => '75A',
120 => '75B',
121 => '36',
122 => 'XXS-XS',
123 => 37,
124 => 38,
125 => '39',
126 => '40',
127 => 'S/M',
128 => '40х38х19 см',
129 => '70C',
130 => '44-46',
131 => 'some',
132 => '1',
133 => '30',
134 => '32',
135 => '34',
136 => '44/46',
137 => 'XXS/XS',
138 => 'XXS',
139 => '52-56',
140 => '102-104',
141 => '102-106',
142 => '102/106',
143 => '106',
145 => '110-112',
144 => '110-114',
146 => '90/94',
147 => '94-98',
148 => '98-102',
149 => '21',
150 => '3',
151 => '40х38х19 sm',
152 => '40х37х19 см',
153 => '40х37х20 см',
154 => '40х38х15 см',
155 => '41х38х15 см',
156 => '39х38х15 см',
];
}

0 comments on commit 9de9797

Please sign in to comment.