19 declare(strict_types=1);
34 $language = $this->getMockBuilder(Language::class)->disableOriginalConstructor()->getMock();
38 #[DataProvider('memberProvider')] 39 public function testAccept(
string $value,
bool $successful): void
41 $language = $this->getMockBuilder(Language::class)->disableOriginalConstructor()->getMock();
44 $this->assertSame($successful, $transformation->accepts($value));
47 #[DataProvider('memberProvider')] 51 $this->expectException(UnexpectedValueException::class);
54 $language = $this->getMockBuilder(Language::class)->disableOriginalConstructor()->getMock();
57 $this->assertSame($value, $transformation->transform($value));
60 #[DataProvider('memberProvider')] 61 public function testApplyTo(
string $value,
bool $successful): void
63 $language = $this->getMockBuilder(Language::class)->disableOriginalConstructor()->getMock();
66 $result = $transformation->applyTo(
new Ok($value));
67 $this->assertSame($successful, $result->isOk());
69 $this->assertSame($value, $result->value());
71 $this->assertInstanceOf(UnexpectedValueException::class, $result->error());
78 'Invalid member.' => [
'hej',
false],
79 'Valid member.' => [
'foo',
true],
A result encapsulates a value or an error and simplifies the handling of those.