Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 82 additions & 82 deletions documentation.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function callsAmount(): int
return count($this->calls);
}

public function toHaveBeenCalledTimes(int $expectedCalls): void
public function calledTimes(int $expectedCalls): void
{
$callsCount = $this->callsAmount();

Expand All @@ -46,7 +46,7 @@ public function toHaveBeenCalledTimes(int $expectedCalls): void
$this->assert($callsCount === $expectedCalls, $message);
}

public function toHaveBeenCalled(): void
public function called(): void
{
$callsCount = $this->callsAmount();

Expand All @@ -57,9 +57,9 @@ public function toHaveBeenCalled(): void
$this->assert($callsCount > 0, $message);
}

public function toHaveBeenCalledOnce(): void
public function calledOnce(): void
{
$this->toHaveBeenCalledTimes(1);
$this->calledTimes(1);
}

public function dd(): never
Expand Down
2 changes: 1 addition & 1 deletion src/Methods/Mocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
if (in_array($methodName, ['__construct', '__get'])
|| in_array($methodName, $methodNames)
|| str_starts_with($methodName, '__moock')
|| $method->isStatic() // TODO: Why did I exclude these from being mocked in the first place?
|| $method->isStatic()
|| $method->isFinal()
) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static function codeToMock(string $code): MockedClassInterface
/**
* @param Closure(Closure(Closure $expectedMethod): Expectation $expect): void $expectation
*/
public static function expect(Closure $expectation): void
public static function verify(Closure $expectation): void
{
$mockExpector = new MockExpector();
$mockExpector->validate($expectation);
Expand Down
10 changes: 5 additions & 5 deletions src/MockMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
$this->methodName = $this->ref->getName();
}

public function filter(mixed ...$filters): static
public function allow(mixed ...$filters): static
{
$this->classMock->__filter($this->methodName, ...$filters);

Expand All @@ -47,14 +47,14 @@ public function void(): static
return $this;
}

public function forceReturn(mixed $returnValue): static
public function returns(mixed $returnValue): static
{
$this->classMock->__replace($this->methodName, fn () => $returnValue);

return $this;
}

public function forceReturnSequence(array $values): static
public function returnsSequence(array $values): static
{
$this->classMock->__replace($this->methodName, function () use (&$values): mixed {
return array_shift($values);
Expand All @@ -66,7 +66,7 @@ public function forceReturnSequence(array $values): static
/**
* @param class-string<Throwable> $exception
*/
public function throwsException(string $exception): static
public function throws(string $exception): static
{
$this->classMock->__replace($this->methodName, function () use ($exception): never {
throw new $exception();
Expand All @@ -75,7 +75,7 @@ public function throwsException(string $exception): static
return $this;
}

public function expect(): Expectation
public function assert(): Expectation
{
return new Expectation(
$this->methodName,
Expand Down
Loading
Loading