gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

NumericComparatorTest.php (2886B)


      1 <?php
      2 /*
      3  * This file is part of the Comparator package.
      4  *
      5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
      6  *
      7  * For the full copyright and license information, please view the LICENSE
      8  * file that was distributed with this source code.
      9  */
     10 
     11 namespace SebastianBergmann\Comparator;
     12 
     13 /**
     14  * @coversDefaultClass SebastianBergmann\Comparator\NumericComparator
     15  *
     16  */
     17 class NumericComparatorTest extends \PHPUnit_Framework_TestCase
     18 {
     19     private $comparator;
     20 
     21     protected function setUp()
     22     {
     23         $this->comparator = new NumericComparator;
     24     }
     25 
     26     public function acceptsSucceedsProvider()
     27     {
     28         return array(
     29           array(5, 10),
     30           array(8, '0'),
     31           array('10', 0),
     32           array(0x74c3b00c, 42),
     33           array(0755, 0777)
     34         );
     35     }
     36 
     37     public function acceptsFailsProvider()
     38     {
     39         return array(
     40           array('5', '10'),
     41           array(8, 5.0),
     42           array(5.0, 8),
     43           array(10, null),
     44           array(false, 12)
     45         );
     46     }
     47 
     48     public function assertEqualsSucceedsProvider()
     49     {
     50         return array(
     51           array(1337, 1337),
     52           array('1337', 1337),
     53           array(0x539, 1337),
     54           array(02471, 1337),
     55           array(1337, 1338, 1),
     56           array('1337', 1340, 5),
     57         );
     58     }
     59 
     60     public function assertEqualsFailsProvider()
     61     {
     62         return array(
     63           array(1337, 1338),
     64           array('1338', 1337),
     65           array(0x539, 1338),
     66           array(1337, 1339, 1),
     67           array('1337', 1340, 2),
     68         );
     69     }
     70 
     71     /**
     72      * @covers       ::accepts
     73      * @dataProvider acceptsSucceedsProvider
     74      */
     75     public function testAcceptsSucceeds($expected, $actual)
     76     {
     77         $this->assertTrue(
     78           $this->comparator->accepts($expected, $actual)
     79         );
     80     }
     81 
     82     /**
     83      * @covers       ::accepts
     84      * @dataProvider acceptsFailsProvider
     85      */
     86     public function testAcceptsFails($expected, $actual)
     87     {
     88         $this->assertFalse(
     89           $this->comparator->accepts($expected, $actual)
     90         );
     91     }
     92 
     93     /**
     94      * @covers       ::assertEquals
     95      * @dataProvider assertEqualsSucceedsProvider
     96      */
     97     public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
     98     {
     99         $exception = null;
    100 
    101         try {
    102             $this->comparator->assertEquals($expected, $actual, $delta);
    103         }
    104 
    105         catch (ComparisonFailure $exception) {
    106         }
    107 
    108         $this->assertNull($exception, 'Unexpected ComparisonFailure');
    109     }
    110 
    111     /**
    112      * @covers       ::assertEquals
    113      * @dataProvider assertEqualsFailsProvider
    114      */
    115     public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
    116     {
    117         $this->setExpectedException(
    118           'SebastianBergmann\\Comparator\\ComparisonFailure', 'matches expected'
    119         );
    120         $this->comparator->assertEquals($expected, $actual, $delta);
    121     }
    122 }