1313class ParserTest extends TestCase
1414{
1515 private Parser $ parser ;
16+ private string $ yaml ;
1617
1718 protected function setUp (): void
1819 {
1920 $ this ->parser = new Parser ();
21+ $ this ->yaml = file_get_contents (__DIR__ . "/fixtures/valid.minimal.yml " );
2022 }
2123
2224 public function testPublicCodeAccessors (): void
2325 {
24- $ yaml = $ this ->getValidPublicCodeYaml ();
25- $ publicCode = $ this ->parser ->parse ($ yaml );
26+ $ publicCode = $ this ->parser ->parse ($ this ->yaml );
2627
2728 $ this ->assertEquals ('Medusa ' , $ publicCode ->getName ());
2829 $ this ->assertEquals ('AGPL-3.0-or-later ' , $ publicCode ->getLicense ());
2930 $ this ->assertEquals (['web ' ], $ publicCode ->getPlatforms ());
3031
31- $ this ->assertNotNull ($ publicCode ->getDescription ('en ' ));
32- $ this ->assertNotNull ($ publicCode ->getDescription ('it ' ));
32+ $ this ->assertNotNull ($ publicCode ->getDescription ('en_GB ' ));
33+ $ this ->assertNull ($ publicCode ->getDescription ('it ' ));
3334
3435 $ maintenance = $ publicCode ->getMaintenance ();
35- $ this ->assertEquals ('internal ' , $ maintenance ['type ' ]);
36+ $ this ->assertEquals ('community ' , $ maintenance ['type ' ]);
3637
3738 $ categories = $ publicCode ->getCategories ();
3839 $ this ->assertContains ('it-development ' , $ categories );
3940 }
4041
4142 public function testToArray (): void
4243 {
43- $ yaml = $ this ->getValidPublicCodeYaml ();
44- $ publicCode = $ this ->parser ->parse ($ yaml );
44+ $ publicCode = $ this ->parser ->parse ($ this ->yaml );
4545
4646 $ array = $ publicCode ->toArray ();
4747 $ this ->assertIsArray ($ array );
@@ -51,66 +51,13 @@ public function testToArray(): void
5151
5252 public function testToJson (): void
5353 {
54- $ yaml = $ this ->getValidPublicCodeYaml ();
55- $ publicCode = $ this ->parser ->parse ($ yaml );
54+ $ publicCode = $ this ->parser ->parse ($ this ->yaml );
5655
5756 $ json = $ publicCode ->toJson ();
5857 $ this ->assertJson ($ json );
5958
6059 $ decoded = json_decode ($ json , true );
60+ var_dump ($ decoded );
6161 $ this ->assertEquals ('Medusa ' , $ decoded ['name ' ]);
6262 }
63-
64- public function testGetDependencies (): void
65- {
66- $ yaml = $ this ->getValidPublicCodeYaml ();
67- $ publicCode = $ this ->parser ->parse ($ yaml );
68-
69- $ deps = $ publicCode ->getDependencies ();
70- $ this ->assertIsArray ($ deps );
71- }
72-
73- private function getValidPublicCodeYaml (): string
74- {
75- return <<<YAML
76- publiccodeYmlVersion: "0.2"
77- name: Medusa
78- url: "https://example.com/medusa"
79- landingURL: "https://github.com/italia/developers-italia-api"
80- releaseDate: "2017-04-15"
81- developmentStatus: stable
82- softwareType: standalone/web
83- platforms:
84- - web
85- categories:
86- - it-development
87- maintenance:
88- type: internal
89- contacts:
90- - name: Francesco Rossi
91- email: "francesco.rossi@comune.reggioemilia.it"
92- legal:
93- license: AGPL-3.0-or-later
94- repoOwner: Comune di Reggio Emilia
95- description:
96- it:
97- shortDescription: >
98- Sistema di gestione documentale
99- longDescription: >
100- Medusa è un sistema di gestione documentale che permette
101- di organizzare e gestire i documenti digitali.
102- features:
103- - Gestione documenti
104- - Workflow documentale
105- en:
106- shortDescription: >
107- Document management system
108- longDescription: >
109- Medusa is a document management system that allows
110- organizing and managing digital documents.
111- features:
112- - Document management
113- - Document workflow
114- YAML ;
115- }
11663}
0 commit comments