Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Stub Laravel Package

codeception/stub

Create lightweight test doubles for PHP with Codeception Stub. Quickly generate stubs and mocks, define method returns and expectations, and override behavior on the fly—ideal for unit tests that need fast, flexible objects without full implementations.

View on GitHub
Deep Wiki
Context7

Codeception\Stub\Expected

public static never($params = null)

Checks if a method never has been invoked

If method invoked, it will immediately throw an exception.

<?php
use \Codeception\Stub\Expected;

$user = $this->make('User', [
     'getName' => Expected::never(),
     'someMethod' => function() {}
]);
$user->someMethod();
  • param mixed $params

public static once($params = null)

Checks if a method has been invoked exactly one time.

If the number is less or greater it will later be checked in verify() and also throw an exception.

<?php
use \Codeception\Stub\Expected;

$user = $this->make(
    'User',
    array(
        'getName' => Expected::once('Davert'),
        'someMethod' => function() {}
    )
);
$userName = $user->getName();
$this->assertEquals('Davert', $userName);

Alternatively, a function can be passed as parameter:

<?php
Expected::once(function() { return Faker::name(); });
  • param mixed $params

public static atLeastOnce($params = null)

Checks if a method has been invoked at least one time.

If the number of invocations is 0 it will throw an exception in verify.

<?php
use \Codeception\Stub\Expected;

$user = $this->make(
    'User',
    array(
        'getName' => Expected::atLeastOnce('Davert')),
        'someMethod' => function() {}
    )
);
$user->getName();
$userName = $user->getName();
$this->assertEquals('Davert', $userName);

Alternatively, a function can be passed as parameter:

<?php
Expected::atLeastOnce(function() { return Faker::name(); });
  • param mixed $params

public static exactly($count, $params = null)

Checks if a method has been invoked a certain amount of times. If the number of invocations exceeds the value it will immediately throw an exception, If the number is less it will later be checked in verify() and also throw an exception.

<?php
use \Codeception\Stub;
use \Codeception\Stub\Expected;

$user = $this->make(
    'User',
    array(
        'getName' => Expected::exactly(3, 'Davert'),
        'someMethod' => function() {}
    )
);
$user->getName();
$user->getName();
$userName = $user->getName();
$this->assertEquals('Davert', $userName);

Alternatively, a function can be passed as parameter:

<?php
Expected::exactly(function() { return Faker::name() });
  • param mixed $params
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4