From ad1b6d20ebff5b471dac2f3425adaf8ddbdf330a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Bu=C3=9Fmann?= Date: Sun, 13 Aug 2017 19:24:00 +0200 Subject: [PATCH] Improved target test --- README.md | 1 - tests/TargetTest.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e451fb..ae353d8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Shooting Target [![Total Downloads](https://poser.pugx.org/patrickbussmann/shooting-target/downloads.png)](https://packagist.org/packages/patrickbussmann/shooting-target) [![StyleCI](https://styleci.io/repos/100169534/shield?branch=master)](https://styleci.io/repos/100169534) [![codecov.io](https://codecov.io/github/patrickbussmann/shooting-target/coverage.svg?branch=master)](https://codecov.io/github/patrickbussmann/shooting-target?branch=master) -[![Coverage Status](https://coveralls.io/repos/github/patrickbussmann/shooting-target/badge.svg?branch=master)](https://coveralls.io/github/patrickbussmann/shooting-target?branch=master) The goal was it to display the hits from the [www.meyton.org/shooting-data-feed-sdf/](Meyton) system. The data source is called Shooting Data Feed (SDF) and could be a XML file or a MySQL database. diff --git a/tests/TargetTest.php b/tests/TargetTest.php index 7e4f6a5..c654098 100644 --- a/tests/TargetTest.php +++ b/tests/TargetTest.php @@ -41,4 +41,33 @@ public function testAddingHits() $target->setHits(); $this->assertEquals([], $target->getHits()); } + + /** + * Test if draw is callable. + */ + public function testDrawTarget() + { + $target = new Target(0.5, 0.5, 2.5, 4, 10); + $target->addHit(new Hit(0, 0, null, '#123456')); + $target->addHit(new Hit(500, 500)); + $target->addHit(new Hit(-500, 500)); + $target->addHit(new Hit(500, -500)); + $target->addHit(new Hit(-500, -500)); + + ob_start(); + $target->draw(); + $pictureString = ob_get_contents(); + ob_end_clean(); + + $this->assertGreaterThanOrEqual(3318000, strlen($pictureString)); + $this->assertLessThanOrEqual(3319000, strlen($pictureString)); + + ob_start(); + $target->draw(20, Target::DRAW_TYPE_GIF); + ob_end_clean(); + + ob_start(); + $target->draw(20, Target::DRAW_TYPE_JPEG); + ob_end_clean(); + } }