|
2 | 2 |
|
3 | 3 | use HiFolks\DataType\Block; |
4 | 4 |
|
5 | | -test('load JSON object HTTP', function (): void { |
| 5 | +test("load JSON object HTTP", function (): void { |
6 | 6 | $jsonString = file_get_contents("./tests/data/story.json"); |
7 | 7 |
|
8 | 8 | $composerContent = Block::fromJsonString($jsonString); |
9 | 9 | expect($composerContent->get("story.name"))->toBe("Home"); |
10 | | - expect($composerContent->getBlock("story.content"))->toBeInstanceOf(Block::class); |
| 10 | + expect($composerContent->getBlock("story.content"))->toBeInstanceOf( |
| 11 | + Block::class, |
| 12 | + ); |
11 | 13 | expect($composerContent->get("story.content"))->toHaveKey("body"); |
12 | 14 | $bodyComponents = $composerContent->getBlock("story.content.body"); |
13 | 15 | expect($bodyComponents)->toHaveCount(10); |
14 | 16 | expect($bodyComponents->get("0.headline"))->toBe("New banner"); |
15 | 17 | expect($bodyComponents->get("1.headline"))->toBe("Hello Everyone"); |
16 | | - expect($bodyComponents->get("2.headline"))->toBe("We don't know what we don't know."); |
| 18 | + expect($bodyComponents->get("2.headline"))->toBe( |
| 19 | + "We don't know what we don't know.", |
| 20 | + ); |
17 | 21 | expect($composerContent->get("cv"))->toBe(1717763755); |
18 | 22 | }); |
19 | 23 |
|
20 | | - |
21 | | -it('load JSON object', function (): void { |
| 24 | +it("load JSON object", function (): void { |
22 | 25 | $file = "./composer.json"; |
23 | 26 | $composerContent = Block::fromJsonFile($file); |
24 | 27 | expect($composerContent->get("name"))->toBe("hi-folks/data-block"); |
|
27 | 30 | expect($composerContent->get("authors.0.name"))->toBe("Test"); |
28 | 31 | }); |
29 | 32 |
|
30 | | -it('export to array', function (): void { |
| 33 | +it("export to array", function (): void { |
31 | 34 | $file = "./composer.json"; |
32 | 35 | $composerContent = Block::fromJsonFile($file); |
33 | 36 | $array = $composerContent->toArray(); |
34 | 37 | expect($array)->toBeArray(); |
35 | | - expect($array)->toHaveKeys(["name","authors"]); |
| 38 | + expect($array)->toHaveKeys(["name", "authors"]); |
36 | 39 | expect($array["authors"])->toHaveKeys([0]); |
37 | 40 | expect($array["authors"][0])->toHaveKeys(["name"]); |
38 | 41 | expect($array["authors"][0]["name"])->toBe("Roberto B."); |
39 | | - |
40 | 42 | }); |
41 | 43 |
|
42 | | - |
43 | | -it('load YAML object', function (): void { |
| 44 | +it("load YAML object", function (): void { |
44 | 45 | $file = "./.github/workflows/run-tests.yml"; |
45 | 46 | $workflow = Block::fromYamlFile($file); |
46 | 47 | expect($workflow->get("on"))->toBeArray(); |
47 | 48 | expect($workflow->get("on"))->toHaveCount(2); |
48 | 49 | expect($workflow->get("on.0"))->toBe("push"); |
49 | 50 | expect($workflow->get("on.1"))->toBe("pull_request"); |
50 | 51 | expect($workflow->get("jobs.test.runs-on"))->toBe('${{ matrix.os }}'); |
51 | | - |
52 | | - |
53 | 52 | }); |
54 | 53 |
|
55 | | -it('Convert Json to Yaml', function (): void { |
| 54 | +it("Convert Json to Yaml", function (): void { |
56 | 55 | $file = "./composer.json"; |
57 | 56 | $composer1 = Block::fromJsonFile($file); |
58 | 57 | $yaml = $composer1->toYaml(); |
59 | 58 | $composer2 = Block::fromYamlString($yaml); |
60 | 59 | expect($composer2->get("name"))->toBe("hi-folks/data-block"); |
61 | 60 | expect($composer2->get("authors.0.name"))->toBe("Roberto B."); |
62 | | - |
63 | | - |
64 | 61 | }); |
65 | 62 |
|
66 | | -it('has some value', function (): void { |
| 63 | +it("has some value", function (): void { |
67 | 64 | $file = "./composer.json"; |
68 | 65 | $composer = Block::fromJsonFile($file); |
69 | 66 | expect($composer->getBlock("require"))->toBeInstanceOf(Block::class); |
70 | 67 | expect($composer->getBlock("require.php"))->toBeInstanceOf(Block::class); |
71 | 68 | expect($composer->get("require.php"))->toBeString(); |
72 | 69 |
|
73 | | - expect($composer->getBlock("require")->has("^8.2|^8.3|^8.4"))->toBeTrue(); |
| 70 | + expect($composer->getBlock("require")->has("^8.3|^8.4|^8.5"))->toBeTrue(); |
74 | 71 | expect($composer->getBlock("require")->hasKey("php"))->toBeTrue(); |
75 | | - expect($composer->getBlock("require-dev")->hasKey("pestphp/pest"))->toBeTrue(); |
| 72 | + expect( |
| 73 | + $composer->getBlock("require-dev")->hasKey("pestphp/pest"), |
| 74 | + )->toBeTrue(); |
76 | 75 | }); |
77 | 76 |
|
78 | | -it('tests some value for composer.lock', function (): void { |
| 77 | +it("tests some value for composer.lock", function (): void { |
79 | 78 | $file = "./tests/data/dummy-composer.lock"; |
80 | 79 | $composer = Block::fromJsonFile($file); |
81 | 80 | expect($composer->getBlock("packages"))->toBeInstanceOf(Block::class); |
82 | 81 | expect($composer->getBlock("packages"))->toHaveCount(7); |
83 | | - expect($composer->getBlock("packages")->where("dist.type", "zip"))->toHaveCount(7); |
84 | | - expect($composer->getBlock("packages")->where("dist.type", "zip"))->toHaveCount(7); |
85 | | - expect($composer->getBlock("packages")->where("source.type", "git"))->toHaveCount(7); |
| 82 | + expect( |
| 83 | + $composer->getBlock("packages")->where("dist.type", "zip"), |
| 84 | + )->toHaveCount(7); |
| 85 | + expect( |
| 86 | + $composer->getBlock("packages")->where("dist.type", "zip"), |
| 87 | + )->toHaveCount(7); |
| 88 | + expect( |
| 89 | + $composer->getBlock("packages")->where("source.type", "git"), |
| 90 | + )->toHaveCount(7); |
86 | 91 | }); |
0 commit comments