File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,12 +2,11 @@ services:
22 morph :
33 platform : linux/amd64
44 container_name : morph-app
5- image : webdevops/php-dev :8.3
5+ image : devitools/hyperf :8.3-dev
66 working_dir : /opt/www
77 volumes :
88 - ./:/opt/www
99 environment :
10- - XDEBUG_MODE=coverage
1110 - SONAR_TOKEN=${SONAR_TOKEN:-undefined}
1211 entrypoint : [ 'tail', '-f', '/dev/null' ]
1312 restart : on-failure
Original file line number Diff line number Diff line change 44
55namespace Morph \Support \Reflective ;
66
7+ use Morph \Type \Collection ;
78use ReflectionClass ;
89use ReflectionException ;
910use ReflectionIntersectionType ;
Original file line number Diff line number Diff line change @@ -45,23 +45,23 @@ final public function count(): int
4545 return count ($ this ->data );
4646 }
4747
48- final public function all (): array
48+ final protected function data (): array
4949 {
5050 return $ this ->data ;
5151 }
5252
53- final public function map ( Closure $ callback ): array
53+ final protected function datum ( ): mixed
5454 {
55- return array_map ( $ callback , $ this ->data ()) ;
55+ return $ this ->data [ $ this -> cursor ] ?? null ;
5656 }
5757
58- final protected function data (): array
58+ public function all (): array
5959 {
6060 return $ this ->data ;
6161 }
6262
63- final protected function datum ( ): mixed
63+ public function map ( Closure $ callback ): array
6464 {
65- return $ this -> data [ $ this ->cursor ] ?? null ;
65+ return array_map ( $ callback , $ this ->data ()) ;
6666 }
6767}
Original file line number Diff line number Diff line change @@ -99,9 +99,9 @@ public function testMapWithErrors(): void
9999 $ messages = [
100100 "The value for 'id' must be of type 'int' and 'string' was given. " ,
101101 "The value for 'price' is required and was not given. " ,
102- "The value for 'more' must be of type 'Serendipity \\Test \\ Testing \\Stub \\NoConstructor' and 'DateTime' was given. " ,
103- "The value for 'no' must be of type 'Serendipity \\Test \\ Testing \\Stub \\NoParameters' and 'string' was given. " ,
104- "The value for 'enum' must be of type 'Serendipity \\Test \\ Testing \\Stub \\Type \\SingleBacked' and 'bool' was given. " ,
102+ "The value for 'more' must be of type 'Morph \\Test \\Stub \\NoConstructor' and 'DateTime' was given. " ,
103+ "The value for 'no' must be of type 'Morph \\Test \\Stub \\NoParameters' and 'string' was given. " ,
104+ "The value for 'enum' must be of type 'Morph \\Test \\Stub \\Type \\SingleBacked' and 'bool' was given. " ,
105105 ];
106106 foreach ($ messages as $ message ) {
107107 if ($ this ->hasErrorMessage ($ errors , $ message )) {
Original file line number Diff line number Diff line change 88use DateTimeInterface ;
99use Morph \Core \Serialize \Resolver \AttributeValue ;
1010use Morph \Exception \Adapter \NotResolved ;
11+ use Morph \Support \Managed ;
1112use Morph \Support \Reflective \Factory \Target ;
1213use Morph \Support \Set ;
1314use Morph \Test \Stub \AttributesVariety ;
1415use PHPUnit \Framework \TestCase ;
15- use Serendipity \Infrastructure \Database \Managed ;
1616
1717use function Morph \Crypt \encrypt ;
1818
Original file line number Diff line number Diff line change 1616
1717final class CollectionValueTest extends TestCase
1818{
19- public function testShouldResolveSuccessfully (): void
20- {
21- // Arrange
22- $ type = $ this ->createMock (ReflectionNamedType::class);
23- $ type ->expects ($ this ->once ())
24- ->method ('getName ' )
25- ->willReturn (FeatureCollection::class);
26- $ parameter = $ this ->createMock (ReflectionParameter::class);
27- $ parameter ->expects ($ this ->once ())
28- ->method ('getType ' )
29- ->willReturn ($ type );
30- $ parameter ->expects ($ this ->once ())
31- ->method ('getName ' )
32- ->willReturn ('features ' );
33-
34- $ faker = $ this ->faker ();
35- $ set = Set::createFrom ([
36- 'features ' => [
37- $ faker ->fake (Feature::class)->toArray (),
38- $ faker ->fake (Feature::class)->toArray (),
39- ],
40- ]);
41- $ collectionValue = new CollectionValue ();
42-
43- // Act
44- $ result = $ collectionValue ->resolve ($ parameter , $ set );
45-
46- // Assert
47- $ this ->assertInstanceOf (FeatureCollection::class, $ result ->content );
48- $ this ->assertCount (2 , $ result ->content );
49- }
50-
5119 public function testShouldResolveWhenTheValueIsNotValid (): void
5220 {
5321 // Arrange
You can’t perform that action at this time.
0 commit comments