RK
Size: a a a
RK
B
B
B
🎃
AH
RK
RK
RK
AH
setSize
, а после кто-то вызовет setWidth
, то получим прямоугольник.AH
AH
class RectangleTest
{
private $rectangle;
public function __construct(Rectangle $rectangle)
{
$this->rectangle = $rectangle;
}
public function testArea()
{
$this->rectangle->setHeight(2);
$this->rectangle->setWidth(3);
// Expect rectangle's area to be 6
}
}
class SquareTest
{
private $rectangle;
public function __construct(Square $rectangle)
{
$this->rectangle = $rectangle;
}
public function testArea()
{
$this->rectangle->setHeight(2);
$this->rectangle->setWidth(3);
// Expect rectangle's area to be 9
}
}
B
RK
class RectangleTest
{
private $rectangle;
public function __construct(Rectangle $rectangle)
{
$this->rectangle = $rectangle;
}
public function testArea()
{
$this->rectangle->setHeight(2);
$this->rectangle->setWidth(3);
// Expect rectangle's area to be 6
}
}
class SquareTest
{
private $rectangle;
public function __construct(Square $rectangle)
{
$this->rectangle = $rectangle;
}
public function testArea()
{
$this->rectangle->setHeight(2);
$this->rectangle->setWidth(3);
// Expect rectangle's area to be 9
}
}
RK
RK
AH
class SquareTest
{
private $rectangle;
public function __construct(Square $rectangle)
{
$this->rectangle = $rectangle;
}
public function testArea()
{
$this->rectangle->setSize(4); // должно вернуть 16
$this->rectangle->setHeight(2);
$this->rectangle->setWidth(3);
// НО вернёт 6
}
}
AH
RK