-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Replaced engine string values by "Engine" enumeration.
- Loading branch information
1 parent
f496049
commit 343117e
Showing
9 changed files
with
161 additions
and
38 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
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,34 @@ | ||
<?php | ||
/* | ||
* This file is part of the HighchartsBundle package. | ||
* | ||
* (c) bibi.nu <bibi@bibi.nu> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HighchartsBundle\Highcharts; | ||
|
||
/** | ||
* The render engine enumeration. | ||
* | ||
* @see ChartInterface::render() | ||
*/ | ||
enum Engine: string | ||
{ | ||
/** | ||
* The JQuery engine. | ||
*/ | ||
case JQUERY = 'jquery'; | ||
/** | ||
* The MooTools engine. | ||
*/ | ||
case MOOTOOLS = 'mootools'; | ||
/** | ||
* No engine. | ||
*/ | ||
case NONE = ''; | ||
} |
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
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,60 @@ | ||
<?php | ||
/* | ||
* This file is part of the HighchartsBundle package. | ||
* | ||
* (c) bibi.nu <bibi@bibi.nu> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace HighchartsBundle\Tests\Highcharts; | ||
|
||
use HighchartsBundle\Highcharts\Engine; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class EngineTest extends TestCase | ||
{ | ||
public static function getInvalidValues(): \Generator | ||
{ | ||
yield ['fake']; | ||
} | ||
|
||
public static function getValues(): \Generator | ||
{ | ||
yield [Engine::JQUERY, 'jquery']; | ||
yield [Engine::MOOTOOLS, 'mootools']; | ||
yield [Engine::NONE, '']; | ||
} | ||
|
||
public function testCount(): void | ||
{ | ||
$values = Engine::cases(); | ||
self::assertCount(3, $values); | ||
} | ||
|
||
#[DataProvider('getValues')] | ||
public function testFrom(Engine $engine, string $value): void | ||
{ | ||
$actual = Engine::from($value); | ||
self::assertSame($actual, $engine); | ||
} | ||
|
||
#[DataProvider('getInvalidValues')] | ||
public function testInvalidValue(string $value): void | ||
{ | ||
self::expectException(\ValueError::class); | ||
Engine::from($value); | ||
self::fail('A value error must be raised.'); | ||
} | ||
|
||
#[DataProvider('getValues')] | ||
public function testValue(Engine $engine, string $expected): void | ||
{ | ||
$actual = $engine->value; | ||
self::assertSame($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
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