Skip to content

Commit

Permalink
Improved target test
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbussmann committed Aug 13, 2017
1 parent e7f5fda commit ad1b6d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 29 additions & 0 deletions tests/TargetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit ad1b6d2

Please sign in to comment.