| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -243,7 +243,7 @@ public function whereLoose($key, $value) | |||
| 243 | 243 | public function first(callable $callback = null, $default = null) | |
| 244 | 244 | { | |
| 245 | 245 | if (is_null($callback)) { | |
| 246 | - return count($this->items) > 0 ? reset($this->items) : null; | ||
| 246 | + return count($this->items) > 0 ? reset($this->items) : value($default); | ||
| 247 | 247 | } | |
| 248 | 248 | ||
| 249 | 249 | return Arr::first($this->items, $callback, $default); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,13 @@ public function testLastWithCallbackAndDefault() | |||
| 34 | 34 | $this->assertEquals('default', $result); | |
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | + public function testLastWithDefaultAndWithoutCallback() | ||
| 38 | + { | ||
| 39 | + $data = new Collection; | ||
| 40 | + $result = $data->last(null, 'default'); | ||
| 41 | + $this->assertEquals('default', $result); | ||
| 42 | + } | ||
| 43 | + | ||
| 37 | 44 | public function testPopReturnsAndRemovesLastItemInCollection() | |
| 38 | 45 | { | |
| 39 | 46 | $c = new Collection(['foo', 'bar']); | |
@@ -688,6 +695,13 @@ public function testFirstWithCallbackAndDefault() | |||
| 688 | 695 | $this->assertEquals('default', $result); | |
| 689 | 696 | } | |
| 690 | 697 | ||
| 698 | + public function testFirstWithDefaultAndWithoutCallback() | ||
| 699 | + { | ||
| 700 | + $data = new Collection; | ||
| 701 | + $result = $data->first(null, 'default'); | ||
| 702 | + $this->assertEquals('default', $result); | ||
| 703 | + } | ||
| 704 | + | ||
| 691 | 705 | public function testGroupByAttribute() | |
| 692 | 706 | { | |
| 693 | 707 | $data = new Collection([['rating' => 1, 'url' => '1'], ['rating' => 1, 'url' => '1'], ['rating' => 2, 'url' => '2']]); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments