| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * TestSuite.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This middleware will intercept traffic from visitors to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * your website. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * PHP version 7.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @category Core | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @package  RedboxTestSuite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @author   Johnny Mast <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @license  https://opensource.org/licenses/MIT MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @link     https://github.com/johnnymast/redbox-testsuite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @since    GIT:1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | namespace Redbox\Testsuite; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | class TestSuite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * Storage to contain the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 8 |  |      * tests. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 8 |  |      * @var \SplObjectStorage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 8 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     protected ?\SplObjectStorage $tests = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * Test Score counter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 4 |  |      * @var int|double | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 4 |  |     protected $score = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 4 |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * TestSuite constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->tests = new \SplObjectStorage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * Reset the score and rewind | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * the tests storage. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function reset() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->score = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 8 |  |      * Attach a Test or an array of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * Tests to the TestSuite. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 8 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 3 |  |      * @param $info The Test to attach. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 3 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 8 |  |     public function attach($info) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         if (is_array($info) === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             foreach ($info as $test) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 $this->attach($test); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 8 |  |             $test = $info; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             // TODO: Allow array of class names and instantiate here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 7 |  |             if (is_string($info) === true && class_exists($info) === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 $test = new $info(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 7 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             if (is_subclass_of($test, Test::class) === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                 throw new \InvalidArgumentException('Type not implementation Test interface.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             $this->tests->attach($test); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * Detach a given test from the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * TestSuite. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @param Test $test The test to detach. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     public function detach(Test $test) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 3 |  |         $this->tests->detach($test); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 3 |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * Check to see if the TestSuite has a given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * test inside. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * @param Test $test The Test to check for. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 2 |  |     public function has(Test $test) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 2 |  |         return $this->tests->contains($test); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * Run the tests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @return int The number of tests that ran. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     public function run(): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $tests_run = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 4 |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 4 |  |          * Reset the test results | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->reset(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         foreach ($this->tests as $test) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 4 |  |             if ($test->run()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 $this->score += $test->score->getScore(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 4 |  |                 $tests_run++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 | 4 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 4 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 4 |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         return $tests_run; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 4 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * Return the test suite score. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @return mixed | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 143 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |     public function getScore() | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |         return $this->score; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 148 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 149 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths