Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Change Arr::toCssClasses to Arr::conditionallyToString to be more abstract #38089

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add one more test to show the benefits
  • Loading branch information
NickSdot committed Jul 21, 2021
commit 96805d81c84845695cb25a0ff228c0495bcab148
22 changes: 20 additions & 2 deletions tests/Support/SupportArrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,25 @@ public function testConditionallyToString()

$this->assertEquals('font-bold mt-4 ml-2', $classes);

$classes = Arr::conditionallyToString([
$values = Arr::conditionallyToString([
'Taylor',
'John',
'Sponge Bob' => false,
'Dave' => true,
], ',');

$this->assertEquals('Taylor,John,Dave', $values);

$values = Arr::conditionallyToString([
'Taylor',
'John',
'Sponge Bob' => false,
'Dave' => true,
], ', ');

$this->assertEquals('Taylor, John, Dave', $values);

$slugParts = Arr::conditionallyToString([
'we',
'do',
'not' => false,
Expand All @@ -838,7 +856,7 @@ public function testConditionallyToString()
'like'
], '-');

$this->assertEquals('we-do-want-to-build-something-slug-like', $classes);
$this->assertEquals('we-do-want-to-build-something-slug-like', $slugParts);
}

public function testWhere()
Expand Down