Goofing off with unit tests

[UPDATE: The library and test have been refactored. See the commit for full details.]

Sometime last year I saw a unit test for the song “Ice Cream Paint Job“.  I thought it was hilarious, and I hate I’ve never been able to find it again.  I liked it so much, in fact, I decided to write my own musical unit integration test.  Behold the MelissaTest, a short, simple test covering the main premise of “Melissa“. Bonus points for me: the test passes.  Enjoy.

<?php
 
namespace MercyfulFate\Album\Melissa\Track;
 
use MercyfulFate\KingDiamond;
use MercyfulFate\Priest;
use MercyfulFate\Witch\Melissa as WitchMelissa;
use MercyfulFate\Album\Melissa\Track\Melissa as TrackMelissa;
 
class MelissaTest extends \PHPUnit_Framework_TestCase
{
 
    /**
     * @var MercyfulFate\KingDiamond
     */
    protected $king;
 
    /**
     * @var MercyfulFate\Priest
     */
    protected $priest;
 
    /**
     * @var MercyfulFate\Witch\Melissa
     */
    protected $witch;
 
    /**
     * @var MercyfulFate\Album\Melissa\Track\Melissa
     */
    protected $trackMelissa;
 
    protected function setUp()
    {
        $this->king = new KingDiamond();
        $this->priest = new Priest();
        $this->priest->attach($this->king);
        $this->witch = new WitchMelissa();
        $this->trackMelissa = new TrackMelissa($this->king, $this->witch, $this->priest);
    }
 
    protected function tearDown()
    {
        $this->trackMelissa = null;
    }
 
    public function testBurnMelissa()
    {
        $this->assertFalse($this->witch->isBurned());
        $this->assertFalse($this->king->swearsRevenge());
 
        $this->trackMelissa->priestBurnsWitch();
 
        $this->assertTrue($this->witch->isBurned());
        $this->assertTrue($this->king->swearsRevenge());
    }
 
}

One thought on “Goofing off with unit tests

  1. The meaning of the phrase “ice cream” varies from one country to another. Phrases such as “frozen custard”, “frozen yogurt”, “sorbet”, “gelato” and others are used to distinguish different varieties and styles. In some countries, such as the United States, the phrase “ice cream” applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">