[PHP] Use parent constructor when inheriting

This commit is contained in:
Arne Jørgensen
2016-03-23 10:59:32 +01:00
parent 5d5a6e049c
commit 0196cdd558
3 changed files with 64 additions and 0 deletions

View File

@@ -375,6 +375,33 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
}
// test inheritance in the model
public function testInheritance()
{
$new_dog = new Swagger\Client\Model\Dog;
// the object should be an instance of the derived class
$this->assertInstanceOf('Swagger\Client\Model\Dog', $new_dog);
// the object should also be an instance of the parent class
$this->assertInstanceOf('Swagger\Client\Model\Animal', $new_dog);
}
// test inheritance constructor is working with data
// initialization
public function testInheritanceConstructorDataInitialization()
{
// initialize the object with data in the constructor
$data = array(
'class_name' => 'Dog',
'breed' => 'Great Dane'
);
$new_dog = new Swagger\Client\Model\Dog($data);
// the property on the derived class should be set
$this->assertSame('Great Dane', $new_dog->getBreed());
// the property on the parent class should be set
$this->assertSame('Dog', $new_dog->getClassName());
}
}
?>