-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3de5469
commit a37c739
Showing
9 changed files
with
546 additions
and
12 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,85 @@ | ||
<?php | ||
|
||
namespace Test\Options\Elements; | ||
|
||
use Halfpastfour\PHPChartJS\Options\Elements\Arc; | ||
use Test\TestUtils; | ||
|
||
/** | ||
* Class ArcTest | ||
* @package Test\Options\Elements | ||
*/ | ||
class ArcTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Arc | ||
*/ | ||
protected $arc; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $data_types = [ | ||
'backgroundColor' => '', /* string */ | ||
'borderColor' => '', /* string */ | ||
'borderWidth' => 1, /* int */ | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $empty_data = [ | ||
'backgroundColor' => null, /* string */ | ||
'borderColor' => null, /* string */ | ||
'borderWidth' => null, /* int */ | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $input_data = [ | ||
'backgroundColor' => 'backgroundColor', /* string */ | ||
'borderColor' => 'borderColor', /* string */ | ||
'borderWidth' => 2, /* int */ | ||
]; | ||
|
||
/** | ||
* | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->arc = new Arc(); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testEmpty() | ||
{ | ||
$expected = $this->empty_data; | ||
$result = TestUtils::getAttributes($this->arc, $this->data_types); | ||
self::assertSame($expected, $result); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testGetAndSetNoObjects() | ||
{ | ||
$expected = $this->input_data; | ||
TestUtils::setAttributes($this->arc, $this->input_data); | ||
$result = TestUtils::getAttributes($this->arc, $this->data_types); | ||
self::assertSame($expected, $result); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testJsonSerialize() | ||
{ | ||
$expected = TestUtils::removeNullsFromArray($this->input_data); | ||
TestUtils::setAttributes($this->arc, $this->input_data); | ||
$result = json_decode($this->arc->jsonSerialize(), true); | ||
self::assertSame($expected, $result); | ||
} | ||
} |
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,109 @@ | ||
<?php | ||
|
||
namespace Test\Options\Elements; | ||
|
||
use Halfpastfour\PHPChartJS\Options\Elements\Line; | ||
use Test\TestUtils; | ||
|
||
/** | ||
* Class LineTest | ||
* @package Test\Options\Elements | ||
*/ | ||
class LineTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Line | ||
*/ | ||
protected $line; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $data_types = [ | ||
'tension' => 1.0, /* float */ | ||
'backgroundColor' => '', /* string */ | ||
'borderWidth' => 1, /* int */ | ||
'borderColor' => '', /* string */ | ||
'borderCapStyle' => '', /* string */ | ||
'borderDash' => [1, 2], /* int[] */ | ||
'borderDashOffset' => 1.0, /* float */ | ||
'borderJoinStyle' => '', /* string */ | ||
'capBezierPoints' => false, /* bool */ | ||
'fill' => '', /* string */ | ||
'stepped' => false, /* bool */ | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $empty_data = [ | ||
'tension' => null, /* float */ | ||
'backgroundColor' => null, /* string */ | ||
'borderWidth' => null, /* int */ | ||
'borderColor' => null, /* string */ | ||
'borderCapStyle' => null, /* string */ | ||
'borderDash' => null, /* int[] */ | ||
'borderDashOffset' => null, /* float */ | ||
'borderJoinStyle' => null, /* string */ | ||
'capBezierPoints' => null, /* bool */ | ||
'fill' => null, /* bool */ | ||
'stepped' => null, /* bool */ | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $input_data = [ | ||
'tension' => 0.2, /* float */ | ||
'backgroundColor' => 'backgroundColor', /* string */ | ||
'borderWidth' => 2, /* int */ | ||
'borderColor' => 'borderColor', /* string */ | ||
'borderCapStyle' => 'borderCapStyle', /* string */ | ||
'borderDash' => [5, 6], /* int[] */ | ||
'borderDashOffset' => 0.1, /* float */ | ||
'borderJoinStyle' => 'borderJoinStyle', /* string */ | ||
'capBezierPoints' => true, /* bool */ | ||
'fill' => true, /* bool */ | ||
'stepped' => true, /* bool */ | ||
]; | ||
|
||
/** | ||
* | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->line = new Line(); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testEmpty() | ||
{ | ||
$expected = $this->empty_data; | ||
$result = TestUtils::getAttributes($this->line, $this->data_types); | ||
self::assertSame($expected, $result); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testGetAndSetNoObjects() | ||
{ | ||
$expected = $this->input_data; | ||
TestUtils::setAttributes($this->line, $this->input_data); | ||
$result = TestUtils::getAttributes($this->line, $this->data_types); | ||
self::assertSame($expected, $result); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testJsonSerialize() | ||
{ | ||
$expected = TestUtils::removeNullsFromArray($this->input_data); | ||
TestUtils::setAttributes($this->line, $this->input_data); | ||
$result = json_decode($this->line->jsonSerialize(), true); | ||
self::assertSame($expected, $result); | ||
} | ||
} |
Oops, something went wrong.