|
@@ 58-69 (lines=12) @@
|
| 55 |
|
static::assertEquals('Player 1', $array['players'][0]['name']); |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
public function testCreateArrayWithUnderScoreNamingStrategy() |
| 59 |
|
{ |
| 60 |
|
$team = new Team('Dream Team'); |
| 61 |
|
$team->setCreatedAt(new \DateTime('2016-01-01')); |
| 62 |
|
|
| 63 |
|
//register custom parser |
| 64 |
|
$object2Array = Object2ArrayBuilder::create()->setNamingStrategy(new UnderscoreNamingStrategy())->build(); |
| 65 |
|
|
| 66 |
|
$array = $object2Array->createArray($team); |
| 67 |
|
static::assertEquals($team->getName(), $array['name']); |
| 68 |
|
static::assertEquals('2016-01-01 00:00:00', $array['created_at']); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
public function testCreateArrayWithNulls() |
| 72 |
|
{ |
|
@@ 71-85 (lines=15) @@
|
| 68 |
|
static::assertEquals('2016-01-01 00:00:00', $array['created_at']); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
public function testCreateArrayWithNulls() |
| 72 |
|
{ |
| 73 |
|
$team = new Team('Dream Team'); |
| 74 |
|
|
| 75 |
|
//register custom parser |
| 76 |
|
$object2Array = Object2ArrayBuilder::create() |
| 77 |
|
->setIgnoreNulls(false) |
| 78 |
|
->build(); |
| 79 |
|
|
| 80 |
|
$array = $object2Array->createArray($team); |
| 81 |
|
|
| 82 |
|
static::assertEquals($team->getName(), $array['name']); |
| 83 |
|
static::assertNull($array['id']); |
| 84 |
|
static::assertNull($array['manager']); |
| 85 |
|
} |
| 86 |
|
} |
| 87 |
|
|