Mockery1.0 Alternative shouldReceive Syntax

Alternative shouldReceive Syntax

As of Mockery 1.0.0, we support calling methods as we would call any PHP method, and not as string arguments to Mockery should* methods.

The two Mockery methods that enable this are allows() and expects().

Allows

We use allows() when we create stubs for methods that return a predefined return value, but for these method stubs we don't care how many times, or if at all, were they called.

$mock = \Mockery::mock('MyClass');
$mock->allows([
    'name_of_method_1' => 'return value',
    'name_of_method_2' => 'return value',
]);

This is equivalent with the following shouldReceive syntax:

$mock = \Mockery::mock('MyClass');
$mock->shouldReceive([
    'name_of_method_1' => 'return value',
    'name_of_method_2' => 'return value',
]);

Note that with this format, we also tell Mockery that we don't care about the arguments to the stubbed methods.

If we do care about the arguments, we would do it like so:

$mock = \Mockery::mock('MyClass');
$mock->allows()
    ->name_of_method_1($arg1)
    ->andReturn('return value');

This is equivalent with the following shouldReceive syntax:

$mock = \Mockery::mock('MyClass');
$mock->shouldReceive('name_of_method_1')
    ->with($arg1)
    ->andReturn('return value');

Expects

We use expects() when we want to verify that a particular method was called:

$mock = \Mockery::mock('MyClass');
$mock->expects()
    ->name_of_method_1($arg1)
    ->andReturn('return value');

This is equivalent with the following shouldReceive syntax:

$mock = \Mockery::mock('MyClass');
$mock->shouldReceive('name_of_method_1')
    ->once()
    ->with($arg1)
    ->andReturn('return value');

By default expects() sets up an expectation that the method should be called once and once only. If we expect more than one call to the method, we can change that expectation:

$mock = \Mockery::mock('MyClass');
$mock->expects()
    ->name_of_method_1($arg1)
    ->twice()
    ->andReturn('return value');

ドキュメント章別ページ

ヘッダー項目移動

注目:アイコン:ページ内リンク設置(リンクがないヘッダーへの移動では、リンクがある以前のヘッダーのハッシュをURLへ付加します。

移動

クリックで即時移動します。

バージョン

設定

適用ボタンクリック後に、全項目まとめて適用されます。

カラーテーマ
和文指定 Pagination
和文指定 Scaffold
Largeスクリーン表示幅
インデント
本文フォント
コードフォント
フォント適用確認

フォントの指定フィールドから、フォーカスが外れると、当ブロックの内容に反映されます。EnglishのDisplayもPreviewしてください。

フォント設定時、表示に不具合が出た場合、当サイトのクッキーを削除してください。

バックスラッシュを含むインライン\Code\Blockの例です。

以下はコードブロックの例です。

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * ユーザに関連する電話レコードを取得
     */
    public function phone()
    {
        return $this->hasOne('App\Phone');
    }
}

設定を保存する前に、表示が乱れないか必ず確認してください。CSSによるフォントファミリー指定の知識がない場合は、フォントを変更しないほうが良いでしょう。

キーボード・ショートカット

オープン操作

PDC

ページ(章)移動の左オフキャンバスオープン

HA

ヘッダー移動モーダルオープン

MS

移動/設定の右オフキャンバスオープン

ヘッダー移動

T

最初のヘッダーへ移動

E

最後のヘッダーへ移動

NJ

次ヘッダー(H2〜H4)へ移動

BK

前ヘッダー(H2〜H4)へ移動

その他

?

このヘルプページ表示
閉じる