From b9a4d39d8f8952947a7a5954489174bdd0104af5 Mon Sep 17 00:00:00 2001 From: Krzysztof Boduch Date: Mon, 26 Mar 2018 13:22:25 +0200 Subject: [PATCH] setFlushThreshold method fix (#290) setFlushThreshold method fix (#290) --- src/Writer.php | 2 +- tests/WriterTest.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Writer.php b/src/Writer.php index 557f0342..934b0e37 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -265,7 +265,7 @@ public function setFlushThreshold($threshold): self throw new TypeError(sprintf(__METHOD__.'() expects 1 Argument to be null or an integer %s given', gettype($threshold))); } - if (null !== $threshold && 1 >= $threshold) { + if (null !== $threshold && 1 > $threshold) { throw new Exception(__METHOD__.'() expects 1 Argument to be null or a valid integer greater or equal to 1'); } diff --git a/tests/WriterTest.php b/tests/WriterTest.php index 373b225e..5d056b06 100644 --- a/tests/WriterTest.php +++ b/tests/WriterTest.php @@ -40,10 +40,17 @@ public function tearDown() */ public function testflushThreshold() { - $this->expectException(Exception::class); $this->csv->setFlushThreshold(12); $this->assertSame(12, $this->csv->getFlushThreshold()); - $this->csv->setFlushThreshold(12); + } + + /** + * @covers ::setFlushThreshold + */ + public function testflushThresholdThrowsException() + { + $this->csv->setFlushThreshold(1); + $this->expectException(Exception::class); $this->csv->setFlushThreshold(0); }