From d6f4e098a4c6163428da445f00ee044c0758c291 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 2 Dec 2016 15:18:33 +0100 Subject: [PATCH] tests --- tests/ValidatorTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 5c0e69f..4c8c617 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -16,6 +16,24 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $validator->isValid(); } + public function testExpectedLegend() + { + $parser = $this->generateParser('example.csv'); + $parser->setHasLegend(true); + + $validator = $this->generateValidator(); + $validator->setExpectedLegend(['foo', 'bar', 'boo']); + $validator->validate($parser); + $this->assertEquals(true, $validator->isValid()); + $this->assertEquals(0, count($validator->getErrors())); + + $validator = $this->generateValidator(); + $validator->setExpectedLegend(['bad', 'legend']); + $validator->validate($parser); + $this->assertEquals(false, $validator->isValid()); + $this->assertEquals(1, count($validator->getErrors())); + } + public function testNoConstraint() { $parser = $this->generateParser('example.csv');