-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,006 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Helper\Arr; | ||
|
||
use Phalcon\Helper\Arr; | ||
use UnitTester; | ||
|
||
/** | ||
* Class ChunkCest | ||
*/ | ||
class ChunkCest | ||
{ | ||
/** | ||
* Tests Phalcon\Helper\Arr :: chunk() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrChunk(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - chunk()'); | ||
|
||
$source = [ | ||
'k1' => 1, | ||
'k2' => 2, | ||
'k3' => 3, | ||
'k4' => 4, | ||
'k5' => 5, | ||
'k6' => 6, | ||
]; | ||
|
||
$expected = [ | ||
[1, 2], | ||
[3, 4], | ||
[5, 6], | ||
]; | ||
$actual = Arr::chunk($source, 2); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Helper\Arr :: chunk() - preserve | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrChunkPreserve(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - chunk() - preserve'); | ||
|
||
$source = [ | ||
'k1' => 1, | ||
'k2' => 2, | ||
'k3' => 3, | ||
'k4' => 4, | ||
'k5' => 5, | ||
'k6' => 6, | ||
]; | ||
|
||
$expected = [ | ||
[ | ||
'k1' => 1, | ||
'k2' => 2, | ||
], | ||
[ | ||
'k3' => 3, | ||
'k4' => 4, | ||
], | ||
[ | ||
'k5' => 5, | ||
'k6' => 6, | ||
], | ||
]; | ||
$actual = Arr::chunk($source, 2, true); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Helper\Arr; | ||
|
||
use Phalcon\Helper\Arr; | ||
use UnitTester; | ||
|
||
/** | ||
* Class FirstCest | ||
*/ | ||
class FirstCest | ||
{ | ||
/** | ||
* Tests Phalcon\Helper\Arr :: first() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrFirst(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - first()'); | ||
$collection = [ | ||
'Phalcon', | ||
'Framework', | ||
]; | ||
|
||
$expected = 'Phalcon'; | ||
$actual = Arr::first($collection); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Helper\Arr; | ||
|
||
use Phalcon\Helper\Arr; | ||
use UnitTester; | ||
|
||
/** | ||
* Class FlattenCest | ||
*/ | ||
class FlattenCest | ||
{ | ||
/** | ||
* Tests Phalcon\Helper\Arr :: flatten() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrFlatten(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - flatten()'); | ||
|
||
$source = [1, [2], [[3], 4], 5]; | ||
$expected = [1, 2, [3], 4, 5]; | ||
$actual = Arr::flatten($source); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Helper\Arr :: flatten() - deep | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrFlattenDeep(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - flatten() - deep'); | ||
|
||
$source = [1, [2], [[3], 4], 5]; | ||
$expected = [1, 2, 3, 4, 5]; | ||
$actual = Arr::flatten($source, true); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Helper\Arr; | ||
|
||
use Phalcon\Helper\Arr; | ||
use UnitTester; | ||
|
||
/** | ||
* Class IsUniqueCest | ||
*/ | ||
class IsUniqueCest | ||
{ | ||
/** | ||
* Tests Phalcon\Helper\Arr :: isUnique() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrIsUnique(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - isUnique()'); | ||
$collection = [ | ||
'Phalcon', | ||
'Framework', | ||
]; | ||
$actual = Arr::isUnique($collection); | ||
$I->assertTrue($actual); | ||
|
||
$collection = [ | ||
'Phalcon', | ||
'Framework', | ||
'Phalcon', | ||
]; | ||
$actual = Arr::isUnique($collection); | ||
$I->assertFalse($actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Helper\Arr; | ||
|
||
use Phalcon\Helper\Arr; | ||
use UnitTester; | ||
|
||
/** | ||
* Class LastCest | ||
*/ | ||
class LastCest | ||
{ | ||
/** | ||
* Tests Phalcon\Helper\Arr :: last() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrLast(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - last()'); | ||
$collection = [ | ||
'Phalcon', | ||
'Framework', | ||
]; | ||
|
||
$expected = 'Framework'; | ||
$actual = Arr::last($collection); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Helper\Arr; | ||
|
||
use Phalcon\Helper\Arr; | ||
use UnitTester; | ||
|
||
/** | ||
* Class OrderCest | ||
*/ | ||
class OrderCest | ||
{ | ||
/** | ||
* Tests Phalcon\Helper\Arr :: order() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-04-06 | ||
*/ | ||
public function helperArrOrder(UnitTester $I) | ||
{ | ||
$I->wantToTest('Helper\Arr - order()'); | ||
$collection = [ | ||
['id' => 2, 'name' => 'Joy'], | ||
['id' => 3, 'name' => 'Khaja'], | ||
['id' => 1, 'name' => 'Raja'], | ||
]; | ||
|
||
$expected = [ | ||
['id' => 1, 'name' => 'Raja'], | ||
['id' => 2, 'name' => 'Joy'], | ||
['id' => 3, 'name' => 'Khaja'], | ||
]; | ||
$actual = Arr::order($collection, 'id'); | ||
$I->assertEquals($expected, $actual); | ||
|
||
$expected = [ | ||
['id' => 3, 'name' => 'Khaja'], | ||
['id' => 2, 'name' => 'Joy'], | ||
['id' => 1, 'name' => 'Raja'], | ||
]; | ||
$actual = Arr::order($collection, 'id', 'desc'); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
Oops, something went wrong.