-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
class UtilsTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function firstReturnsFirstItemInCollection() | ||
{ | ||
$c = $this->coll(['foo', 'bar']); | ||
$this->assertEquals('foo', $c->first()); | ||
} | ||
|
||
/** @test */ | ||
public function lastReturnsLastItemInCollection() | ||
{ | ||
$c = $this->coll(['foo', 'bar']); | ||
$this->assertEquals('bar', $c->last()); | ||
} | ||
|
||
/** @test */ | ||
public function firstWithCallback() | ||
{ | ||
$data = $this->coll(['foo', 'bar', 'baz']); | ||
|
||
$result = $data->first(function ($key, $value) { | ||
return $value === 'bar'; | ||
}); | ||
|
||
$this->assertEquals('bar', $result); | ||
} | ||
|
||
/** @test */ | ||
public function firstWithCallbackAndDefault() | ||
{ | ||
$data = $this->coll(['foo', 'bar']); | ||
|
||
$result = $data->first(function ($key, $value) { | ||
return $value === 'baz'; | ||
}, 'default'); | ||
|
||
$this->assertEquals('default', $result); | ||
} | ||
|
||
/** @test */ | ||
public function shiftReturnsAndRemovesFirstItemInCollection() | ||
{ | ||
$c = $this->coll(['foo', 'bar']); | ||
|
||
$this->assertEquals('foo', $c->shift()); | ||
$this->assertEquals('bar', $c->first()); | ||
} | ||
|
||
/** @test */ | ||
public function popReturnsAndRemovesLastItemInCollection() | ||
{ | ||
$c = $this->coll(['foo', 'bar']); | ||
|
||
$this->assertEquals('bar', $c->pop()); | ||
$this->assertEquals('foo', $c->first()); | ||
} | ||
|
||
/** @test */ | ||
public function it_should_be_uppered() | ||
{ | ||
$this->assertEquals('BAR', $this->lib('inflector')->upper('bar')); | ||
} | ||
|
||
/** @test */ | ||
public function it_should_be_lowered() | ||
{ | ||
$this->assertEquals('bar', $this->lib('inflector')->lower('BAR')); | ||
} | ||
} |