PayPal\Test\Common\ModelTest::testNestedClassConversion PHP Method

testNestedClassConversion() public method

    public function testNestedClassConversion()
    {
        $n = new ArrayClass();
        $n->setName("test");
        $n->setDescription("description");
        $o = new NestedClass();
        $o->setId('123');
        $o->setInfo($n);
        $this->assertEquals("123", $o->getId());
        $this->assertEquals("test", $o->getInfo()->getName());
        $json = $o->toJSON();
        $this->assertEquals('{"id":"123","info":{"name":"test","description":"description"}}', $json);
        $newO = new NestedClass();
        $newO->fromJson($json);
        $this->assertEquals($o, $newO);
    }