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

UtilTest.php (8148B)


      1 <?php
      2 /**
      3  * PHP_CodeCoverage
      4  *
      5  * Copyright (c) 2009-2014, Sebastian Bergmann <sebastian@phpunit.de>.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  *
     12  *   * Redistributions of source code must retain the above copyright
     13  *     notice, this list of conditions and the following disclaimer.
     14  *
     15  *   * Redistributions in binary form must reproduce the above copyright
     16  *     notice, this list of conditions and the following disclaimer in
     17  *     the documentation and/or other materials provided with the
     18  *     distribution.
     19  *
     20  *   * Neither the name of Sebastian Bergmann nor the names of his
     21  *     contributors may be used to endorse or promote products derived
     22  *     from this software without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  *
     37  * @category   PHP
     38  * @package    CodeCoverage
     39  * @subpackage Tests
     40  * @author     Sebastian Bergmann <sebastian@phpunit.de>
     41  * @copyright  2009-2014 Sebastian Bergmann <sebastian@phpunit.de>
     42  * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
     43  * @link       http://github.com/sebastianbergmann/php-code-coverage
     44  * @since      File available since Release 1.0.0
     45  */
     46 
     47 if (!defined('TEST_FILES_PATH')) {
     48     define(
     49       'TEST_FILES_PATH',
     50       dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR .
     51       '_files' . DIRECTORY_SEPARATOR
     52     );
     53 }
     54 
     55 require_once TEST_FILES_PATH . 'CoverageClassExtendedTest.php';
     56 require_once TEST_FILES_PATH . 'CoverageClassTest.php';
     57 require_once TEST_FILES_PATH . 'CoverageFunctionTest.php';
     58 require_once TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php';
     59 require_once TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php';
     60 require_once TEST_FILES_PATH . 'CoverageMethodTest.php';
     61 require_once TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php';
     62 require_once TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php';
     63 require_once TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php';
     64 require_once TEST_FILES_PATH . 'CoverageNoneTest.php';
     65 require_once TEST_FILES_PATH . 'CoverageNotPrivateTest.php';
     66 require_once TEST_FILES_PATH . 'CoverageNotProtectedTest.php';
     67 require_once TEST_FILES_PATH . 'CoverageNotPublicTest.php';
     68 require_once TEST_FILES_PATH . 'CoveragePrivateTest.php';
     69 require_once TEST_FILES_PATH . 'CoverageProtectedTest.php';
     70 require_once TEST_FILES_PATH . 'CoveragePublicTest.php';
     71 require_once TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php';
     72 require_once TEST_FILES_PATH . 'CoveredClass.php';
     73 require_once TEST_FILES_PATH . 'CoveredFunction.php';
     74 require_once TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php';
     75 require_once TEST_FILES_PATH . 'NamespaceCoverageClassTest.php';
     76 require_once TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php';
     77 require_once TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php';
     78 require_once TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php';
     79 require_once TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php';
     80 require_once TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php';
     81 require_once TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php';
     82 require_once TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php';
     83 require_once TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php';
     84 require_once TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php';
     85 require_once TEST_FILES_PATH . 'NamespaceCoveredClass.php';
     86 require_once TEST_FILES_PATH . 'NotExistingCoveredElementTest.php';
     87 require_once TEST_FILES_PATH . 'CoverageNothingTest.php';
     88 /**
     89  * Tests for the PHP_CodeCoverage_Util class.
     90  *
     91  * @category   PHP
     92  * @package    CodeCoverage
     93  * @subpackage Tests
     94  * @author     Sebastian Bergmann <sebastian@phpunit.de>
     95  * @copyright  2009-2014 Sebastian Bergmann <sebastian@phpunit.de>
     96  * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
     97  * @link       http://github.com/sebastianbergmann/php-code-coverage
     98  * @since      Class available since Release 1.0.0
     99  */
    100 class PHP_CodeCoverage_UtilTest extends PHPUnit_Framework_TestCase
    101 {
    102     /**
    103      * @covers PHP_CodeCoverage_Util::getLinesToBeIgnored
    104      */
    105     public function testGetLinesToBeIgnored()
    106     {
    107         $this->assertEquals(
    108           array(
    109              1 => TRUE,
    110              3 => TRUE,
    111              4 => TRUE,
    112              5 => TRUE,
    113              7 => TRUE,
    114              8 => TRUE,
    115              9 => TRUE,
    116             10 => TRUE,
    117             11 => TRUE,
    118             12 => TRUE,
    119             13 => TRUE,
    120             14 => TRUE,
    121             15 => TRUE,
    122             16 => TRUE,
    123             17 => TRUE,
    124             18 => TRUE,
    125             19 => TRUE,
    126             20 => TRUE,
    127             21 => TRUE,
    128             22 => TRUE,
    129             23 => TRUE,
    130             24 => TRUE,
    131             25 => TRUE,
    132             26 => TRUE,
    133             27 => TRUE,
    134             30 => TRUE,
    135             32 => TRUE,
    136             33 => TRUE,
    137             34 => TRUE,
    138             35 => TRUE,
    139             36 => TRUE,
    140             37 => TRUE,
    141             38 => TRUE,
    142           ),
    143           PHP_CodeCoverage_Util::getLinesToBeIgnored(
    144             TEST_FILES_PATH . 'source_with_ignore.php'
    145           )
    146         );
    147     }
    148 
    149     /**
    150      * @covers PHP_CodeCoverage_Util::getLinesToBeIgnored
    151      */
    152     public function testGetLinesToBeIgnored2()
    153     {
    154         $this->assertEquals(
    155           array(1 => TRUE),
    156           PHP_CodeCoverage_Util::getLinesToBeIgnored(
    157             TEST_FILES_PATH . 'source_without_ignore.php'
    158           )
    159         );
    160     }
    161 
    162     public function testGetLinesToBeIgnored3()
    163     {
    164         $this->assertEquals(
    165           array(
    166             1 => TRUE,
    167             2 => TRUE,
    168             8 => TRUE,
    169             15 => TRUE,
    170             3 => TRUE,
    171             4 => TRUE,
    172             19 => TRUE,
    173             16 => TRUE
    174           ),
    175           PHP_CodeCoverage_Util::getLinesToBeIgnored(
    176             TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php'
    177           )
    178         );
    179     }
    180 
    181     /**
    182      * @covers PHP_CodeCoverage_Util::getLinesToBeIgnored
    183      */
    184     public function testGetLinesToBeIgnoredOneLineAnnotations()
    185     {
    186         $this->assertEquals(
    187           array(
    188             1 => TRUE,
    189             2 => TRUE,
    190             3 => TRUE,
    191             4 => TRUE,
    192             5 => TRUE,
    193             6 => TRUE,
    194             7 => TRUE,
    195             8 => TRUE,
    196             9 => TRUE,
    197             10 => TRUE,
    198             11 => TRUE,
    199             12 => TRUE,
    200             13 => TRUE,
    201             14 => TRUE,
    202             17 => TRUE,
    203             19 => TRUE,
    204             22 => TRUE,
    205             23 => TRUE,
    206             27 => TRUE,
    207             28 => TRUE,
    208             29 => TRUE,
    209             30 => TRUE,
    210             31 => TRUE,
    211             32 => TRUE,
    212             33 => TRUE,
    213           ),
    214           PHP_CodeCoverage_Util::getLinesToBeIgnored(
    215             TEST_FILES_PATH . 'source_with_oneline_annotations.php'
    216           )
    217         );
    218     }
    219 
    220 
    221     /**
    222      * @covers PHP_CodeCoverage_Util::percent
    223      */
    224     public function testPercent()
    225     {
    226         $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 0));
    227         $this->assertEquals(100, PHP_CodeCoverage_Util::percent(100, 100));
    228         $this->assertEquals(
    229           '100.00%', PHP_CodeCoverage_Util::percent(100, 100, TRUE)
    230         );
    231     }
    232 }