/** * @test */ public function testListConversion() { $c1 = new SimpleModelTestClass(); $c1->setField1("a")->setField2('value'); $c2 = new SimpleModelTestClass(); $c1->setField1("another")->setField2('object'); $parent = new ListModelTestClass(); $parent->setList1(array('simple', 'list', 'with', 'integer', 'keys')); $parent->setList2(array($c1, $c2)); $parentCopy = new ListModelTestClass(); $parentCopy->fromJson($parent->toJSON()); $this->assertEquals($parent, $parentCopy); }
/** * @dataProvider EmptyNullProvider * @param string|null $field2 * @param bool $matches */ public function testEmptyNullConversion($field2, $matches) { $c1 = new SimpleModelTestClass(); $c1->setField1("a")->setField2($field2); $this->assertTrue(strpos($c1->toJSON(), "field2") !== !$matches); }