测试构造函数的更好方法 - phpunit

时间:2015-03-06 11:00:29

标签: php unit-testing symfony zend-framework phpunit

这是我为测试类的构造函数而编写的测试用例。这是错的,还有其他更好的方法吗?

/**
 * Set values of an edge
 *
 * @param string|int $point1 starting point of an edge
 * @param string|int $point2 end point of an edge
 * @param int $value of an edge
 */
public function __construct($point1, $point2, $value)
{
    $this->setPoint1($point1);
    $this->setPoint2($point2);
    $this->setValue($value);
}

/**
 * Test for class constructor
 */
public function testConstructor()
{
    $edgeObj = new Edge('x', 'y', 15.25);
    $this->assertEquals('x', $edgeObj->getPoint1());
    $this->assertEquals('y', $edgeObj->getPoint2());
    $this->assertEquals(15.25, $edgeObj->getValue());
}

0 个答案:

没有答案