1
0
Fork 0
wow-raid-bingo/tests/Unit/Support/SetTest.php
2021-10-18 11:56:52 +02:00

81 lines
1.9 KiB
PHP

<?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());
}
}