From 33476890da1b7282ffaf097fb7c9c7fdfcd61cfd Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Oct 2017 09:57:04 +0100 Subject: [PATCH] Smaller Tests - make avoidNonLinks test smaller. One assert per test. This makes it easier to deal with failures. Before, if the first line in the data file failed, none of the subsequent lines would run. Now every line will always run, and you can get clear output of which ones passed and which ones failed! --- tests/Misd/Linkify/Test/LinkifyTest.php | 17 +++++++++++++---- tests/Misd/Linkify/Test/ProcessEmailsTest.php | 9 +++------ tests/Misd/Linkify/Test/ProcessTest.php | 9 +++------ tests/Misd/Linkify/Test/ProcessUrlsTest.php | 9 +++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/Misd/Linkify/Test/LinkifyTest.php b/tests/Misd/Linkify/Test/LinkifyTest.php index a940cc4..927b4cf 100644 --- a/tests/Misd/Linkify/Test/LinkifyTest.php +++ b/tests/Misd/Linkify/Test/LinkifyTest.php @@ -46,10 +46,19 @@ public function emailProvider() public function ignoreProvider() { - return array( - array($this->loadData('ignore.json')), - array($this->loadData('ignore-options.json')), - ); + $out = array(); + foreach(array( + $this->loadData('ignore.json'), + $this->loadData('ignore-options.json'), + ) as $data) { + foreach($data['tests'] as $test) { + $out[] = array( + $data['options'], + $test, + ); + } + } + return $out; } public function callbackProvider() diff --git a/tests/Misd/Linkify/Test/ProcessEmailsTest.php b/tests/Misd/Linkify/Test/ProcessEmailsTest.php index 91b58b6..3c91082 100644 --- a/tests/Misd/Linkify/Test/ProcessEmailsTest.php +++ b/tests/Misd/Linkify/Test/ProcessEmailsTest.php @@ -73,12 +73,9 @@ public function avoidUrlLinks(array $data) * @test * @dataProvider ignoreProvider */ - public function avoidNonLinks(array $data) + public function avoidNonLinks(array $options, $test) { - $linkify = new Linkify($data['options']); - - foreach ($data['tests'] as $test) { - $this->assertEquals($test, $linkify->processEmails($test)); - } + $linkify = new Linkify($options); + $this->assertEquals($test, $linkify->processEmails($test)); } } diff --git a/tests/Misd/Linkify/Test/ProcessTest.php b/tests/Misd/Linkify/Test/ProcessTest.php index 7e57ff8..b8e88d8 100644 --- a/tests/Misd/Linkify/Test/ProcessTest.php +++ b/tests/Misd/Linkify/Test/ProcessTest.php @@ -70,12 +70,9 @@ public function makeEmailLinks(array $data) * @test * @dataProvider ignoreProvider */ - public function avoidNonLinks(array $data) + public function avoidNonLinks(array $options, $test) { - $linkify = new Linkify($data['options']); - - foreach ($data['tests'] as $test) { - $this->assertEquals($test, $linkify->process($test)); - } + $linkify = new Linkify($options); + $this->assertEquals($test, $linkify->process($test)); } } diff --git a/tests/Misd/Linkify/Test/ProcessUrlsTest.php b/tests/Misd/Linkify/Test/ProcessUrlsTest.php index cfef7a9..1e59479 100644 --- a/tests/Misd/Linkify/Test/ProcessUrlsTest.php +++ b/tests/Misd/Linkify/Test/ProcessUrlsTest.php @@ -69,12 +69,9 @@ public function avoidEmailLinks(array $data) * @test * @dataProvider ignoreProvider */ - public function avoidNonLinks(array $data) + public function avoidNonLinks(array $options, $test) { - $linkify = new Linkify($data['options']); - - foreach ($data['tests'] as $test) { - $this->assertEquals($test, $linkify->processUrls($test)); - } + $linkify = new Linkify($options); + $this->assertEquals($test, $linkify->processUrls($test)); } }