當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Input::shouldReceive方法代碼示例

本文整理匯總了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']);
     });
 }
開發者ID:JamesForks,項目名稱:sortable,代碼行數:59,代碼來源:SortableTraitTest.php

示例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);
 }
開發者ID:dalabarge,項目名稱:validating,代碼行數:6,代碼來源:ValidatingTraitTest.php


注:本文中的Illuminate\Support\Facades\Input::shouldReceive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。