<?php

require_once dirname(__FILE__) . '/../../src/KataRomanNumerals.class.php';

/**
 * Test class for KataRomanNumerals.
 * Generated by PHPUnit on 2011-02-09 at 21:39:12.
 */
class KataRomanNumeralsTest extends PHPUnit_Framework_TestCase
{

  /**
   * @var KataRomanNumerals
   */
  protected $romanNumeral;

  /**
   * Sets up the fixture, for example, opens a network connection.
   * This method is called before a test is executed.
   */
  protected function setUp()
  {
    $this->romanNumeral = new KataRomanNumerals();
  }

  /*
   * @expectedException Exception
   */
  public function testNumberIsOutOfRange()
  {
    try {
      $this->romanNumeral->isValidIntegerNumber(3001);
      $this->romanNumeral->isValidIntegerNumber(0);
      $this->romanNumeral->isValidIntegerNumber(-10);
      $this->romanNumeral->isValidIntegerNumber(10.2);
    } catch (Exception $exc) {
      return;
    }
    $this->fail('An expected exception has not been raised.');
  }

  public function testIsValidIntegerNumber()
  {
    $this->assertEquals($this->romanNumeral->isValidIntegerNumber(1), true);
    $this->assertEquals($this->romanNumeral->isValidIntegerNumber(100), true);
    $this->assertEquals($this->romanNumeral->isValidIntegerNumber(500), true);
    $this->assertEquals($this->romanNumeral->isValidIntegerNumber(1000), true);
    $this->assertEquals($this->romanNumeral->isValidIntegerNumber(3000), true);
  }

  /**
   * @dataProvider provider
   */
  public function testConvertIntegerToRoman($integerToConvert, $romanExpected)
  {
    $this->assertEquals($this->romanNumeral->integerToRoman($integerToConvert),$romanExpected);
  }

  public function provider()
  {
      return array(
          array(1,"I"), array(5,"V"), array(10,"X"), array(50,"L"),
          array(100,"C"), array(500,"D"), array(1000, "M"),array(199,"CXCIX"),
          array(3000, "MMM"), array(499, "CDXCIX"), array(24,'XXIV'), array(4,"IV")
      );
  }

}

?>
