CalculatorTest.php 718 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yguern
  5. * Date: 29/09/2017
  6. * Time: 09:01
  7. */
  8. namespace Cloud\RDexp\Calculator;
  9. class CalculatorTest extends \PHPUnit_Framework_TestCase
  10. {
  11. /**
  12. * What : try to add non real number 10 + 'test'
  13. * Expected : An exception must be thrown
  14. */
  15. public function testAddNonRealNumber() {
  16. $calculator = new Calculator();
  17. try {
  18. $calculator->add(10, 'test');
  19. $this->assertFalse(true, "An exception must be thrown");
  20. } catch (\Exception $e) {
  21. $this->assertInstanceOf(CalculatorException::class, $e);
  22. $this->assertEquals("Adding not real numbers", $e->getMessage());
  23. }
  24. }
  25. }