/** * @test */ public function test_build_as_datetime_assoc_array() { $rule = FilterRule::newRule()->withArrayRule()->includes(['b']); $builder = EncoderBuilder::ofAssocArray($rule); $values = ['a' => new \DateTime('2015/12/13 14:15:36', new \DateTimeZone('Asia/Tokyo')), 'b' => new \DateTime('2008/2/29 11:59:59', new \DateTimeZone('Asia/Tokyo')), 'c' => new \DateTime('2000/11/10 9:8:7', new \DateTimeZone('Asia/Tokyo'))]; $result = $builder->strategy()->serialize($values, $builder->formatters()); $this->assertEquals(['b' => '2008-02-29T11:59:59+0900'], $result); $serializer = $builder->build($values); $result2 = $serializer->jsonSerialize(); $this->assertEquals(['b' => '2008-02-29T11:59:59+0900'], $result2); }
private function newRule(array $fieldNames) { return \JsonEncoder\FilterRule::newRule()->includes($fieldNames); }