<?php
use PHPUnit\Framework\TestCase;
class DependsTest extends TestCase
{
public function testSetValue() : Foo
{
$foo = new Foo();
$this->assertNull($foo->getValue());
$foo->setValue(4);
$this->assertEquals(4, $foo->getValue());
// returned $foo is param of dependent tests
return $foo;
}
/**
* These two tests doesn't really have a dependency
* but it's only to show how the depends annotation works
*
* @depends testSetValue
*/
public function testAddIntToValue($foo) : void
{
$this->assertEquals(5, $foo->addIntToValue(1));
}
}
class Foo
{
private $value;
public function getValue()
{
return $this->value;
}
public function setValue($value)
{
$this->value = $value;
}
public function addIntToValue($int)
{
return $this->value + $int;
}
}