Skip to content

Commit

Permalink
Adjust and add tests for join modifier. Ref #3001
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Dec 11, 2020
1 parent 3f8a220 commit 59d651a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/Modifiers/JoinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,31 @@

class JoinTest extends TestCase
{
/** @test */
public function it_joins_values_of_an_array_using_a_comma_by_default()
{
$joined = $this->modify(['foo', 'bar']);

$this->assertEquals('foo, bar', $joined);
}

/** @test */
public function it_joins_values_of_an_array_using_a_custom_delimiter()
{
$joined = $this->modify(['foo', 'bar'], '+');

$this->assertEquals('foo+bar', $joined);
}

/** @test */
public function it_returns_empty_string_when_value_is_null()
{
$joined = $this->modify(null);
$joined = $this->modify(null, ' ');

$this->assertEquals('', $joined);
}

public function modify($arr, $delimiter = ' ')
public function modify($arr, $delimiter = null)
{
return Modify::value($arr)->join($delimiter)->fetch();
}
Expand Down

0 comments on commit 59d651a

Please sign in to comment.