20250203
This commit is contained in:
67
tests/extensions/ArrayExtensionTest.php
Normal file
67
tests/extensions/ArrayExtensionTest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace goodboyalex\php_components_pack\tests\extensions;
|
||||
|
||||
use goodboyalex\php_components_pack\extensions\ArrayExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ArrayExtensionTest extends TestCase
|
||||
{
|
||||
|
||||
public function testRemoveEmpties ()
|
||||
{
|
||||
$this->PrepareForTest();
|
||||
|
||||
$array = [
|
||||
'a' => 'a',
|
||||
'b' => 'b',
|
||||
'c' => '',
|
||||
'd' => null,
|
||||
'e' => 0,
|
||||
'f' => false
|
||||
];
|
||||
|
||||
$this->assertEquals([
|
||||
'a' => 'a',
|
||||
'b' => 'b',
|
||||
'e' => 0,
|
||||
'f' => false
|
||||
], ArrayExtension::RemoveEmpties($array));
|
||||
}
|
||||
|
||||
private function PrepareForTest (): void
|
||||
{
|
||||
require_once __DIR__ . '/../../sources/extensions/ArrayExtension.php';
|
||||
}
|
||||
|
||||
public function testIsStringKey ()
|
||||
{
|
||||
$this->PrepareForTest();
|
||||
|
||||
$this->assertTrue(ArrayExtension::IsStringKey('a'));
|
||||
$this->assertFalse(ArrayExtension::IsStringKey(1));
|
||||
|
||||
}
|
||||
|
||||
public function testGetAssociativePart ()
|
||||
{
|
||||
$this->PrepareForTest();
|
||||
|
||||
$array = [
|
||||
'a' => 'a',
|
||||
'b' => 'b',
|
||||
'c' => 'c',
|
||||
'd' => 'd',
|
||||
'e',
|
||||
'f'
|
||||
];
|
||||
|
||||
$this->assertEquals([
|
||||
'a' => 'a',
|
||||
'b' => 'b',
|
||||
'c' => 'c',
|
||||
'd' => 'd'
|
||||
], ArrayExtension::GetAssociativePart($array));
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user