Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3938447
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/tests/Output/HTMLOutputTest.php b/tests/Output/HTMLOutputTest.php
index aa692eb..9faf232 100644
--- a/tests/Output/HTMLOutputTest.php
+++ b/tests/Output/HTMLOutputTest.php
@@ -1,37 +1,30 @@
<?php
namespace Keruald\Reporting\Tests\Output;
use Keruald\Reporting\Output\HTMLOutput;
use Keruald\Reporting\Report;
use Keruald\Reporting\Tests\WithSampleReport;
use PHPUnit\Framework\TestCase;
class HTMLOutputTest extends TestCase {
use WithSampleReport;
- ///
- /// Initialization
- //
-
- public Report $report;
-
- protected function setUp () : void {
- $this->report = $this->buildSampleReport();
- }
-
///
/// Tests
//
- public function testRender () : void {
- $actual = HTMLOutput::for($this->report)
- ->render();
+ /**
+ * @dataProvider provideSampleReports
+ */
+ public function testRender (string $name, Report $report) : void {
+ $actual = HTMLOutput::for($report)->render();
- $expected = file_get_contents($this->getDataDir() . "/report.html");
+ $expected = file_get_contents($this->getDataDir() . "/$name.html");
$this->assertEquals($expected, $actual);
}
+
}
diff --git a/tests/Output/MarkdownOutputTest.php b/tests/Output/MarkdownOutputTest.php
index 749934c..89b3bfd 100644
--- a/tests/Output/MarkdownOutputTest.php
+++ b/tests/Output/MarkdownOutputTest.php
@@ -1,37 +1,29 @@
<?php
namespace Keruald\Reporting\Tests\Output;
use Keruald\Reporting\Output\MarkdownOutput;
use Keruald\Reporting\Report;
use Keruald\Reporting\Tests\WithSampleReport;
use PHPUnit\Framework\TestCase;
class MarkdownOutputTest extends TestCase {
use WithSampleReport;
- ///
- /// Initialization
- //
-
- public Report $report;
-
- protected function setUp () : void {
- $this->report = $this->buildSampleReport();
- }
-
///
/// Tests
//
- public function testRender () : void {
- $actual = MarkdownOutput::for($this->report)
- ->render();
+ /**
+ * @dataProvider provideSampleReports
+ */
+ public function testRender (string $name, Report $report) : void {
+ $actual = MarkdownOutput::for($report)->render();
- $expected = file_get_contents($this->getDataDir() . "/report.md");
+ $expected = file_get_contents($this->getDataDir() . "/$name.md");
$this->assertEquals($expected, $actual);
}
}
diff --git a/tests/Output/XMLOutputTest.php b/tests/Output/XMLOutputTest.php
index 99d7c61..472352e 100644
--- a/tests/Output/XMLOutputTest.php
+++ b/tests/Output/XMLOutputTest.php
@@ -1,39 +1,31 @@
<?php
namespace Keruald\Reporting\Tests\Output;
use Keruald\Reporting\Output\XMLOutput;
use Keruald\Reporting\Report;
use Keruald\Reporting\Tests\WithSampleReport;
use PHPUnit\Framework\TestCase;
class XMLOutputTest extends TestCase {
use WithSampleReport;
- ///
- /// Initialization
- //
-
- public Report $report;
-
- protected function setUp () : void {
- $this->report = $this->buildSampleReport();
- }
-
///
/// Tests
//
- public function testRender () : void {
- $actual = XMLOutput::for($this->report)
- ->render();
+ /**
+ * @dataProvider provideSampleReports
+ */
+ public function testRender (string $name, Report $report) : void {
+ $actual = XMLOutput::for($report)->render();
- $expected = file_get_contents($this->getDataDir() . "/report.xml");
+ $expected = file_get_contents($this->getDataDir() . "/$name.xml");
$this->assertEquals($expected, $actual);
}
}
diff --git a/tests/WithSampleReport.php b/tests/WithSampleReport.php
index e6f140e..38aa781 100644
--- a/tests/WithSampleReport.php
+++ b/tests/WithSampleReport.php
@@ -1,58 +1,71 @@
<?php
namespace Keruald\Reporting\Tests;
use Keruald\Reporting\Report;
use Keruald\Reporting\ReportEntry;
use Keruald\Reporting\ReportSection;
trait WithSampleReport {
public function getDataDir () : string {
return __DIR__ . "/data";
}
+ public function provideSampleReports () : iterable {
+ yield ["report", $this->buildSampleReport()];
+ yield ["empty", new Report("Void report")];
+
+ $report = $this->buildSampleReport();
+ $report->properties = [];
+ yield ["no_metadata", $report];
+
+ $report = $this->buildSampleReport();
+ $report->sections = [];
+ yield ["only_metadata", $report];
+ }
+
public function buildSampleReport () : Report {
$report = new Report("Sneakers");
// Section 1
$section = new ReportSection("Air Max");
$section->entries = [
new ReportEntry("Air Max 90", "One of the more icon color is the infrared."),
new ReportEntry("Air Max 95", "Launched in 1995, designed by Sergio Lozano."),
new ReportEntry("Air Max 97", <<<EOF
Well highlighted Air bubble.
Inspired by mountain bikes, while an urban legend quotes Japan bullet trains as inspiration.
EOF
),
];
$report->push($section);
// Section 2
$section = new ReportSection("Other Nike Air");
$section->entries = [
new ReportEntry("Introduction", "Because there are other sneakers than Air Max."),
new ReportEntry("Air Force 1", "« Air Force 1. Zéro fan, que des fanatiques. » -- LTA"),
];
$report->push($section);
// Section 3 — should be ignored as blank
$section = new ReportSection("Not cool sneakers");
// As all sneakers are cool, this is empty.
$report->pushIfNotEmpty($section);
// Section 4 — should be included even if blank
$section = new ReportSection("👟");
$report->push($section);
// Metadata
$report->properties = [
"Date" => "9999-99-99",
"Topic" => "Urban culture",
];
return $report;
}
}
diff --git a/tests/data/empty.html b/tests/data/empty.html
new file mode 100644
index 0000000..a60ce4d
--- /dev/null
+++ b/tests/data/empty.html
@@ -0,0 +1 @@
+<h1 id="void-report">Void report</h1>
diff --git a/tests/data/empty.md b/tests/data/empty.md
new file mode 100644
index 0000000..ef838e9
--- /dev/null
+++ b/tests/data/empty.md
@@ -0,0 +1 @@
+# Void report
diff --git a/tests/data/empty.xml b/tests/data/empty.xml
new file mode 100644
index 0000000..73a9f19
--- /dev/null
+++ b/tests/data/empty.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<report title="Void report"/>
diff --git a/tests/data/no_metadata.html b/tests/data/no_metadata.html
new file mode 100644
index 0000000..f24afbf
--- /dev/null
+++ b/tests/data/no_metadata.html
@@ -0,0 +1,15 @@
+<h1 id="sneakers">Sneakers</h1>
+<h2 id="air-max">Air Max</h2>
+<h3 id="air-max-90">Air Max 90</h3>
+<p>One of the more icon color is the infrared.</p>
+<h3 id="air-max-95">Air Max 95</h3>
+<p>Launched in 1995, designed by Sergio Lozano.</p>
+<h3 id="air-max-97">Air Max 97</h3>
+<p>Well highlighted Air bubble.</p>
+<p>Inspired by mountain bikes, while an urban legend quotes Japan bullet trains as inspiration.</p>
+<h2 id="other-nike-air">Other Nike Air</h2>
+<h3 id="introduction">Introduction</h3>
+<p>Because there are other sneakers than Air Max.</p>
+<h3 id="air-force-1">Air Force 1</h3>
+<p>« Air Force 1. Zéro fan, que des fanatiques. » -- LTA</p>
+<h2 id="%F0%9F%91%9F">👟</h2>
diff --git a/tests/data/no_metadata.md b/tests/data/no_metadata.md
new file mode 100644
index 0000000..a5f38bd
--- /dev/null
+++ b/tests/data/no_metadata.md
@@ -0,0 +1,29 @@
+# Sneakers
+
+## Air Max
+
+### Air Max 90
+
+One of the more icon color is the infrared.
+
+### Air Max 95
+
+Launched in 1995, designed by Sergio Lozano.
+
+### Air Max 97
+
+Well highlighted Air bubble.
+
+Inspired by mountain bikes, while an urban legend quotes Japan bullet trains as inspiration.
+
+## Other Nike Air
+
+### Introduction
+
+Because there are other sneakers than Air Max.
+
+### Air Force 1
+
+« Air Force 1. Zéro fan, que des fanatiques. » -- LTA
+
+## 👟
diff --git a/tests/data/no_metadata.xml b/tests/data/no_metadata.xml
new file mode 100644
index 0000000..9602b74
--- /dev/null
+++ b/tests/data/no_metadata.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<report title="Sneakers">
+ <section title="Air Max">
+ <entry title="Air Max 90">
+ <text>One of the more icon color is the infrared.</text>
+ </entry>
+ <entry title="Air Max 95">
+ <text>Launched in 1995, designed by Sergio Lozano.</text>
+ </entry>
+ <entry title="Air Max 97">
+ <text>Well highlighted Air bubble.
+
+Inspired by mountain bikes, while an urban legend quotes Japan bullet trains as inspiration.</text>
+ </entry>
+ </section>
+ <section title="Other Nike Air">
+ <entry title="Introduction">
+ <text>Because there are other sneakers than Air Max.</text>
+ </entry>
+ <entry title="Air Force 1">
+ <text>« Air Force 1. Zéro fan, que des fanatiques. » -- LTA</text>
+ </entry>
+ </section>
+ <section title="👟"/>
+</report>
diff --git a/tests/data/only_metadata.html b/tests/data/only_metadata.html
new file mode 100644
index 0000000..b1cf11d
--- /dev/null
+++ b/tests/data/only_metadata.html
@@ -0,0 +1,14 @@
+<h1 id="sneakers">Sneakers</h1>
+<h2 id="report-properties">Report properties</h2>
+<table>
+ <tbody>
+ <tr>
+ <th>Date</th>
+ <td>9999-99-99</td>
+ </tr>
+ <tr>
+ <th>Topic</th>
+ <td>Urban culture</td>
+ </tr>
+ </tbody>
+</table>
diff --git a/tests/data/only_metadata.md b/tests/data/only_metadata.md
new file mode 100644
index 0000000..e2a21db
--- /dev/null
+++ b/tests/data/only_metadata.md
@@ -0,0 +1,6 @@
+# Sneakers
+
+| Property | |
+|----------|---------------|
+| Date | 9999-99-99 |
+| Topic | Urban culture |
diff --git a/tests/data/only_metadata.xml b/tests/data/only_metadata.xml
new file mode 100644
index 0000000..5e3c2f0
--- /dev/null
+++ b/tests/data/only_metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<report title="Sneakers">
+ <data title="Properties">
+ <entry>
+ <key>Date</key>
+ <value>9999-99-99</value>
+ </entry>
+ <entry>
+ <key>Topic</key>
+ <value>Urban culture</value>
+ </entry>
+ </data>
+</report>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Dec 26, 02:14 (17 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314385
Default Alt Text
(10 KB)
Attached To
Mode
rKREPORT Keruald Report
Attached
Detach File
Event Timeline
Log In to Comment