Skip to content

Commit 5dcb33b

Browse files
committed
test: use minimal file for interface tests
1 parent 25dc5e3 commit 5dcb33b

File tree

2 files changed

+59
-62
lines changed

2 files changed

+59
-62
lines changed

tests/ParserTest.php

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@
1313
class 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
}

tests/fixtures/valid.minimal.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
publiccodeYmlVersion: "0"
2+
3+
name: Medusa
4+
url: "https://github.com/italia/developers.italia.it.git"
5+
6+
platforms:
7+
- web
8+
9+
categories:
10+
- cloud-management
11+
12+
developmentStatus: development
13+
14+
softwareType: "standalone/other"
15+
16+
description:
17+
en_GB:
18+
localisedName: Medusa
19+
shortDescription: >
20+
A rather short description which
21+
is probably useless
22+
longDescription: >
23+
Very long description of this software, also split
24+
on multiple rows. You should note what the software
25+
is and why one should need it. This is 158 characters.
26+
Very long description of this software, also split
27+
on multiple rows. You should note what the software
28+
is and why one should need it. This is 316 characters.
29+
Very long description of this software, also split
30+
on multiple rows. You should note what the software
31+
is and why one should need it. This is 474 characters.
32+
Very long description of this software, also split
33+
on multiple rows. You should note what the software
34+
is and why one should need it. This is 632 characters.
35+
features:
36+
- Just one feature
37+
38+
legal:
39+
license: AGPL-3.0-or-later
40+
41+
maintenance:
42+
type: "community"
43+
44+
contacts:
45+
- name: Francesco Rossi
46+
47+
localisation:
48+
localisationReady: true
49+
availableLanguages:
50+
- en

0 commit comments

Comments
 (0)