Overview

Namespaces

  • None
  • tests
    • unit
      • barebones
        • utilities
      • lib

Classes

  • TestCase
  • tests\unit\barebones\utilities\ArraysTest
  • tests\unit\barebones\utilities\MathTest
  • tests\unit\BaseUnitTestCase
  • tests\unit\lib\BrowserIdentificationTest
  • tests\unit\lib\PathManagerTest
  • tests\unit\lib\UrlManagerTest
  • tests\unit\lib\VariantRulesTest
  • tests\unit\lib\VariantsManagerTest
  • Overview
  • Namespace
  • Class
 1: <?php
 2: namespace tests\unit\barebones\utilities;
 3: use Math;
 4: use tests\integration\barebones\BarebonesTestCase;
 5: 
 6: /**
 7:  * #2 pencils only
 8:  */
 9: class MathTest extends BarebonesTestCase
10: {
11:     public function testOrdinal()
12:     {
13:         $this->assertEquals(Math::ordinal(1), '1st');
14:         $this->assertEquals(Math::ordinal('1'), '1st');
15:         $this->assertEquals(Math::ordinal('2'), '2nd');
16:         $this->assertEquals(Math::ordinal('3'), '3rd');
17:         $this->assertEquals(Math::ordinal('4'), '4th');
18:         $this->assertEquals(Math::ordinal('0'), '');
19:         $this->assertEquals(Math::ordinal('-25'), '');
20:         $this->assertEquals(Math::ordinal('ya mama'), '');
21:     }
22: 
23:     public function testIsNegative()
24:     {
25:         $this->assertTrue(Math::isNegative('-1.00'));
26:         $this->assertTrue(Math::isNegative(-1.00));
27:         $this->assertTrue(Math::isNegative('(1.00)'));
28: 
29:         $this->assertNotTrue(Math::isNegative('1.00'));
30:         $this->assertNotTrue(Math::isNegative(1.00));
31: 
32:         $this->assertNotTrue(Math::isNegative('0.00'));
33:         $this->assertNotTrue(Math::isNegative(0));
34:         $this->assertNotTrue(Math::isNegative(0.00));
35:     }
36: 
37:     public function testTally()
38:     {
39:         $this->assertEquals(Math::tally('(2.111111111111)', 0), '(2.11)');
40:         $this->assertEquals(Math::tally('-2.111111111111', 0), '(2.11)');
41:         $this->assertEquals(Math::tally('(2.11)', '(3.00)'), '(5.11)');
42:         $this->assertEquals(Math::tally('-2.11', '-3.00'), '(5.11)');
43:         $this->assertEquals(Math::tally('-2.11', '3.00'), '0.89');
44:         $this->assertEquals(Math::tally('2.11', '-3.00'), '(0.89)');
45:         $this->assertEquals(Math::tally('2.11', '3.00'), '5.11');
46:     }
47: }
48: 
API documentation generated by ApiGen