本文整理汇总了PHP中Illuminate\Support\Facades\Input::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::shouldReceive方法的具体用法?PHP Input::shouldReceive怎么用?PHP Input::shouldReceive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::shouldReceive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCriteria
public function testCriteria()
{
$this->specify("sort criterion is applied when only one is given", function () {
$this->assertCount(1, (array) TestModelWithSortableMethod::sorted(['sort' => 'field1,asc'])->getQuery()->orders);
});
$this->specify("sort criteria are applied when array is given", function () {
$this->assertCount(2, (array) TestModelWithSortableMethod::sorted(['field1,asc', 'field2,desc'])->getQuery()->orders);
});
$this->specify("sort criterion is applied when only one is given", function () {
$this->assertCount(1, (array) TestModelWithSortableMethod::sorted(['sort' => 'field1,asc'])->getQuery()->orders);
});
$this->specify("sort criteria are applied when array is given", function () {
$this->assertCount(2, (array) TestModelWithSortableMethod::sorted(['field1,asc', 'field2,desc'])->getQuery()->orders);
});
$this->specify("criteria are applied only to sortable parameters", function () {
$this->assertCount(0, (array) TestModelWithSortableMethod::sorted('field0,asc')->getQuery()->orders);
$this->assertCount(1, (array) TestModelWithSortableMethod::sorted(['field0,asc', 'field1,desc'])->getQuery()->orders);
$this->assertCount(2, (array) TestModelWithSortableMethod::sorted(['sort' => ['field0,asc', 'field1,desc', 'field2,desc']])->getQuery()->orders);
$this->assertCount(2, (array) TestModelWithSortableMethod::sorted(['field0,asc', 'field1,desc', 'field2,desc', 'field3,desc'])->getQuery()->orders);
});
$this->specify("criteria are applied to columns by name", function () {
$criterion = (array) TestModelWithSortableMethod::sorted('field1,asc')->getQuery()->orders[0];
$this->assertEquals('field1', $criterion['column']);
});
$this->specify("criteria are applied in the same order as specified", function () {
$criteria = (array) TestModelWithSortableMethod::sorted(['field1,desc', 'field2,desc'])->getQuery()->orders;
$this->assertEquals('field1', $criteria[0]['column']);
$this->assertEquals('field2', $criteria[1]['column']);
$criteria = (array) TestModelWithSortableMethod::sorted(['field2,desc', 'field1,desc'])->getQuery()->orders;
$this->assertEquals('field2', $criteria[0]['column']);
$this->assertEquals('field1', $criteria[1]['column']);
});
$this->specify('getSearchableAttribues is not required, if $searchable property exists', function () {
$criteria = (array) TestModelWithSortableProperty::sorted(['field2,desc', 'field1,desc'])->getQuery()->orders;
$this->assertEquals('field2', $criteria[0]['column']);
$this->assertEquals('field1', $criteria[1]['column']);
});
$this->specify('model must implement getSortableAttributes() or have $sortable property', function () {
TestModel::sorted(['field1,desc', 'field2,desc']);
}, ['throws' => new RuntimeException()]);
$this->specify('* in searchable field list makes all fields searchable', function () {
$criteria = (array) TestModelWithAllFieldsSortable::sorted(['field2,desc', 'field42,desc'])->getQuery()->orders;
$this->assertEquals('field2', $criteria[0]['column']);
$this->assertEquals('field42', $criteria[1]['column']);
});
$this->specify('available callback method is used in lieu of standard sorting', function () {
$criteria = (array) TestModelWithSortableCallbackMethod::sorted(['created_at,desc'])->getQuery()->orders;
$this->assertEquals('created', $criteria[0]['column']);
$this->assertEquals('desc', $criteria[0]['direction']);
});
$this->specify('default sorting criteria are applued', function () {
Input::shouldReceive('input')->andReturn(null);
$criteria = (array) TestModelWithDefaultSortingCriteria::sorted()->getQuery()->orders;
$this->assertEquals('column1', $criteria[0]['column']);
$this->assertEquals('desc', $criteria[0]['direction']);
$this->assertEquals('column2', $criteria[1]['column']);
$this->assertEquals('asc', $criteria[1]['direction']);
});
}
示例2: testGetConfirmationAttributes
public function testGetConfirmationAttributes()
{
Input::shouldReceive('all')->once()->andReturn(['password' => 'foo', 'password_confirmation' => 'bar']);
$result = $this->trait->getConfirmationAttributes();
$this->assertEquals(['password_confirmation' => 'bar'], $result);
}