Skip to content

Commit 48956f0

Browse files
authored
Test Matrix does not invoke ReleasesInterface::all() when invalid constraint (#63)
1 parent 1b95a8f commit 48956f0

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/Matrices/Matrix.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{
1515
public function __construct(
1616
private ReleasesInterface $releases,
17-
private VersionParser $versionParser = new VersionParser(),
17+
private VersionParser $versionParser = new VersionParser,
1818
) {}
1919

2020
/**
@@ -36,6 +36,5 @@ public function satisfiedBy(string $constraint): array
3636
previous: $e
3737
);
3838
}
39-
4039
}
4140
}

tests/Unit/Matrices/MatrixTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Tests\Unit\Matrices;
66

77
use Mockery;
8+
use Throwable;
89
use TypistTech\PhpMatrix\Exceptions\UnexpectedValueException;
910
use TypistTech\PhpMatrix\Matrices\Matrix;
1011
use TypistTech\PhpMatrix\Matrices\MatrixInterface;
@@ -81,5 +82,22 @@
8182

8283
$matrix->satisfiedBy('invalid constraint');
8384
})->throws(UnexpectedValueException::class);
85+
86+
it('does not invoke ReleasesInterface::all() when invalid constraint', function () {
87+
$releases = Mockery::mock(ReleasesInterface::class);
88+
89+
$releases->expects()
90+
->all()
91+
->withAnyArgs()
92+
->never();
93+
94+
$matrix = new Matrix($releases);
95+
96+
try {
97+
$matrix->satisfiedBy('invalid constraint');
98+
} catch (Throwable $e) {
99+
// No-op.
100+
}
101+
});
84102
});
85103
});

0 commit comments

Comments
 (0)