Initial Commit
This commit is contained in:
commit
ddf09fe00c
113 changed files with 187148 additions and 0 deletions
81
tests/Unit/Support/SetTest.php
Normal file
81
tests/Unit/Support/SetTest.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Support;
|
||||
|
||||
use App\Support\Set;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SetTest extends TestCase
|
||||
{
|
||||
public function test_constructor_sets_values()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => false, 'three' => true]);
|
||||
|
||||
$this->assertSame(['one', 'three'], $set->all()->toArray());
|
||||
}
|
||||
|
||||
public function test_set_method()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
|
||||
|
||||
$set->set("two", false);
|
||||
|
||||
$this->assertSame(['one', 'three'], $set->all()->toArray());
|
||||
|
||||
$set->set("four");
|
||||
|
||||
$this->assertSame(['one', 'three', 'four'], $set->all()->toArray());
|
||||
}
|
||||
|
||||
public function test_fill_method()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
|
||||
|
||||
$set->fill(["five" => true, "six" => true, "seven" => false ]);
|
||||
|
||||
$this->assertSame(['five', 'six'], $set->all()->toArray());
|
||||
}
|
||||
|
||||
public function test_has_method()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
|
||||
|
||||
$this->assertTrue($set->has('one'));
|
||||
$this->assertFalse($set->has('four'));
|
||||
}
|
||||
|
||||
public function test_toggle_method()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
|
||||
|
||||
$set->toggle('two');
|
||||
$set->toggle('four');
|
||||
|
||||
$this->assertSame(['one', 'three', 'four'], $set->all()->toArray());
|
||||
}
|
||||
|
||||
public function test_count_method()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
|
||||
|
||||
$this->assertSame(3, $set->count());
|
||||
}
|
||||
|
||||
public function test_clear_method()
|
||||
{
|
||||
$set = new Set(['one' => true, 'two' => true, 'three' => true]);
|
||||
|
||||
$set->clear();
|
||||
|
||||
$this->assertSame([], $set->all()->toArray());
|
||||
}
|
||||
|
||||
public function test_to_array_method()
|
||||
{
|
||||
$arr = ['one' => true, 'two' => true];
|
||||
|
||||
$set = new Set($arr);
|
||||
$this->assertSame($arr, $set->toArray());
|
||||
}
|
||||
}
|
||||
Reference in a new issue