I am doing some unit testing in Symfony2 which I am quiet new to. I have a very basic class:
<?php
namespace MyBundle\TestBundle\Dto;
class AddressResponse
{
/**
* @var string
*/
public $name;
/**
* @var boolean
*/
public $surname;
/**
* @var array
*/
public $addresses = array();
/**
* @param $name
* @param $surname
* @param array $addresses
*/
public function __construct($name, $surname, array $addresses)
{
$this->name = $name;
$this->surname = $surname;
$this->addresses = $addresses;
}
}
My Test Class:
<?php
namespace MyBundle\TestBundle\Tests\Dto;
use MyBundle\TestBundle\Dto\AddressResponse;
/**
* Generated by PHPUnit_SkeletonGenerator on 2015-05-19 at 14:01:52.
*/
class AddressResponseTest extends \PHPUnit_Framework_TestCase
{
/**
* @var AddressResponse
*/
protected $object;
public $name;
public $surname;
public $address = array();
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = $this->createAddressResponseInstance();
}
public function createAddressResponseInstance()
{
return new AddressResponse(
$this->name,
$this->surname,
$this->address
);
}
public function testAddressResponse()
{
$this->assertTrue($this->object->name, $this->object->surname, $this->object->addresses);
}
}
The above test is all I could come up for my simple calss to test but i get this error message: Cannot assert null on true.
And how else could I test my simple class apart form AssertTrue
Aucun commentaire:
Enregistrer un commentaire