forked from halfpastfouram/phpchartjs
-
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.
Adds some assertArraySubset due to recursive retrieval of fields.
- Loading branch information
Showing
9 changed files
with
244 additions
and
55 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
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,184 @@ | ||
<?php | ||
|
||
namespace Test\Delegate; | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; | ||
|
||
|
||
/** | ||
* Class ArraySerializableTest | ||
* @package Test\Delegate | ||
*/ | ||
class ArraySerializableTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var A | ||
*/ | ||
private $classA; | ||
|
||
/** | ||
* @var B | ||
*/ | ||
private $classB; | ||
|
||
/** | ||
* | ||
*/ | ||
public function setUp() { | ||
$this->classA = new A(1, 2); | ||
$this->classB = new B(3, 4, 5, 6); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testSuperclass() { | ||
$expected = ['a' => 1, 'b' => 2]; | ||
ksort($expected); | ||
$result = $this->classA->getArrayCopy(); | ||
ksort($result); | ||
self::assertSame($expected, $result); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testSubclass() { | ||
$expected = ['a' => 3, 'b' => 4, 'c' => 5, 'd' => 6]; | ||
ksort($expected); | ||
$result = $this->classB->getArrayCopy(); | ||
ksort($result); | ||
self::assertSame($expected, $result); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Class A | ||
* @package Delegate | ||
*/ | ||
class A | ||
{ | ||
use ArraySerializable; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $a; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $b; | ||
|
||
/** | ||
* A constructor. | ||
* | ||
* @param $a int | ||
* @param $b int | ||
*/ | ||
public function __construct( $a, $b) | ||
{ | ||
$this->a = $a; | ||
$this->b = $b; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getA() | ||
{ | ||
return $this->a; | ||
} | ||
|
||
/** | ||
* @param int $a | ||
*/ | ||
public function setA( $a ) | ||
{ | ||
$this->a = $a; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getB() | ||
{ | ||
return $this->b; | ||
} | ||
|
||
/** | ||
* @param int $b | ||
*/ | ||
public function setB( $b ) | ||
{ | ||
$this->b = $b; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Class B | ||
* @package Delegate | ||
*/ | ||
class B extends A | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private $c; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $d; | ||
|
||
/** | ||
* B constructor. | ||
* | ||
* @param $a int | ||
* @param $b int | ||
* @param $c int | ||
* @param $d int | ||
*/ | ||
public function __construct( $a, $b, $c, $d ) | ||
{ | ||
parent::__construct( $a, $b ); | ||
$this->c = $c; | ||
$this->d = $d; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getC() | ||
{ | ||
return $this->c; | ||
} | ||
|
||
/** | ||
* @param int $c | ||
*/ | ||
public function setC( $c ) | ||
{ | ||
$this->c = $c; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getD() | ||
{ | ||
return $this->d; | ||
} | ||
|
||
/** | ||
* @param int $d | ||
*/ | ||
public function setD( $d ) | ||
{ | ||
$this->d = $d; | ||
} | ||
} |
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
Oops, something went wrong.