mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-26 09:02:53 -04:00 
			
		
		
		
	From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type: - `setUpBeforeClass()` - `setUp()` - `assertPreConditions()` - `assertPostConditions()` - `tearDown()` - `tearDownAfterClass()` - `onNotSuccessfulTest()` [1]: https://phpunit.de/announcements/phpunit-8.html
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * Invoice Ninja (https://invoiceninja.com).
 | |
|  *
 | |
|  * @link https://github.com/invoiceninja/invoiceninja source repository
 | |
|  *
 | |
|  * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
 | |
|  *
 | |
|  * @license https://www.elastic.co/licensing/elastic-license
 | |
|  */
 | |
| 
 | |
| namespace Tests\Unit;
 | |
| 
 | |
| use Illuminate\Foundation\Testing\DatabaseTransactions;
 | |
| use Tests\TestCase;
 | |
| 
 | |
| /**
 | |
|  * @test
 | |
|  */
 | |
| class RangeDetectionTest extends TestCase
 | |
| {
 | |
|     protected function setUp() :void
 | |
|     {
 | |
|         parent::setUp();
 | |
|     }
 | |
| 
 | |
|     public function test_range_detection()
 | |
|     {
 | |
|         $ranges = [];
 | |
|         $ranges[] = [100, 105];
 | |
|         $ranges[] = [106, 110];
 | |
|         $ranges[] = [110, 115];
 | |
| 
 | |
|         $expanded_ranges = [];
 | |
| 
 | |
|         foreach ($ranges as $range) {
 | |
|             $expanded_ranges = array_merge(array_values($expanded_ranges), array_values($this->makeRanges($range)));
 | |
|         }
 | |
| 
 | |
|         $value_count_array = array_count_values($expanded_ranges);
 | |
| 
 | |
|         $value_count_array = array_diff($value_count_array, [1]);
 | |
| 
 | |
|         $this->assertEquals(count($value_count_array), 1);
 | |
|     }
 | |
| 
 | |
|     private function makeRanges(array $range)
 | |
|     {
 | |
|         return range($range[0], $range[1]);
 | |
|     }
 | |
| }
 |