|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Smoren\ArrayView\Tests\Unit\Utils; |
| 6 | + |
| 7 | +use Smoren\ArrayView\Exceptions\IndexError; |
| 8 | +use Smoren\ArrayView\Util; |
| 9 | + |
| 10 | +class IsArraySequentialTest extends \Codeception\Test\Unit |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @dataProvider dataProviderForIsSequentialTrue |
| 14 | + */ |
| 15 | + public function testIsSequentialTrue(array $source) |
| 16 | + { |
| 17 | + $this->assertTrue(Util::isArraySequential($source)); |
| 18 | + $this->assertTrue(Util::isArraySequential($source, true)); |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * @dataProvider dataProviderForIsSequentialFalse |
| 23 | + */ |
| 24 | + public function testIsSequentialFalse(array $source) |
| 25 | + { |
| 26 | + $this->assertFalse(Util::isArraySequential($source)); |
| 27 | + $this->assertFalse(Util::isArraySequential($source, true)); |
| 28 | + } |
| 29 | + |
| 30 | + public function dataProviderForIsSequentialTrue(): array |
| 31 | + { |
| 32 | + return [ |
| 33 | + [[]], |
| 34 | + [['']], |
| 35 | + [[null]], |
| 36 | + [[1]], |
| 37 | + [['1']], |
| 38 | + [['test']], |
| 39 | + [[1, 2, 3]], |
| 40 | + [[0 => 1, 1 => 2, 2 => 3]], |
| 41 | + [['0' => 1, 1 => 2, 2 => 3]], |
| 42 | + [['0' => 1, '1' => 2, '2' => 3]], |
| 43 | + [[10, '20', 30.5]], |
| 44 | + ]; |
| 45 | + } |
| 46 | + |
| 47 | + public function dataProviderForIsSequentialFalse(): array |
| 48 | + { |
| 49 | + return [ |
| 50 | + [['a' => 1]], |
| 51 | + [[1 => 1]], |
| 52 | + [[0 => 1, 1 => 2, 3 => 3]], |
| 53 | + [[0 => 1, 1 => 2, 2 => 3, 'test' => 123]], |
| 54 | + [[1 => 2, 2 => 3]], |
| 55 | + [[1 => 2, 3 => 3, 'a' => 1000]], |
| 56 | + ]; |
| 57 | + } |
| 58 | +} |
0 commit comments