mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add tests for color helper
This commit is contained in:
parent
4382adce85
commit
49136a4d67
|
@ -73,10 +73,14 @@ class Helper
|
|||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v3.3]
|
||||
* @return array
|
||||
* @return string
|
||||
*/
|
||||
public static function defaultChartColors($index = 0)
|
||||
public static function defaultChartColors(int $index = 0)
|
||||
{
|
||||
if ($index < 0) {
|
||||
$index = 0;
|
||||
}
|
||||
|
||||
$colors = [
|
||||
'#008941',
|
||||
'#FF4A46',
|
||||
|
@ -359,8 +363,8 @@ class Helper
|
|||
if($index < 0) {
|
||||
$index = 0;
|
||||
}
|
||||
elseif($index > 265) {
|
||||
$index = 265;
|
||||
elseif($index >($total_colors - 1)) {
|
||||
$index = $total_colors - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Statuslabel;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Asset;
|
||||
|
||||
class DefaultColorKeyTest extends TestCase
|
||||
{
|
||||
public function DefaultColorKeyTest()
|
||||
{
|
||||
Statuslabel::factory()->hasAssets(1)->count(255)->create();
|
||||
|
||||
$this->defaultChartColors($index);
|
||||
|
||||
$this->assertArrayHasKey('index', ($index)[0]);
|
||||
|
||||
|
||||
}
|
||||
}
|
19
tests/Unit/Helpers/HelperTest.php
Normal file
19
tests/Unit/Helpers/HelperTest.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Helpers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HelperTest extends TestCase
|
||||
{
|
||||
public function testDefaultChartColorsMethodHandlesHighValues()
|
||||
{
|
||||
$this->assertIsString(Helper::defaultChartColors(1000));
|
||||
}
|
||||
|
||||
public function testDefaultChartColorsMethodHandlesNegativeNumbers()
|
||||
{
|
||||
$this->assertIsString(Helper::defaultChartColors(-1));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue