Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
royvanv committed Nov 15, 2021
1 parent d8cab18 commit a314614
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 63 deletions.
105 changes: 52 additions & 53 deletions tests/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Vendeka\Text\Tests;

use Vendeka\Text\Text;
use Vendeka\Text\Words;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
Expand All @@ -14,65 +13,65 @@ public function testNormalizeWhitespaceMethod(): void
$this->assertIsString(Str::normalizeWhitespace('Instance'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->normalizeWhitespace());

$this->assertEquals('White space', Str::normalizeWhitespace(" White\r\n space "));
$this->assertEquals('White space', Str::of("White space\t")->normalizeWhitespace());
}
$this->assertEquals('White space', Str::normalizeWhitespace(" White\r\n space "));
$this->assertEquals('White space', Str::of("White space\t")->normalizeWhitespace());
}

public function testToWordsMethod (): void
{
$this->assertInstanceOf(Words::class, Str::toWords('Instance'));
$this->assertInstanceOf(Words::class, Str::of('Instance')->toWords());
public function testToWordsMethod(): void
{
$this->assertInstanceOf(Words::class, Str::toWords('Instance'));
$this->assertInstanceOf(Words::class, Str::of('Instance')->toWords());

$this->assertEquals('a dog', (string) Str::toWords('a dog'));
$this->assertEquals('a snake', Str::toWords('a_snake')->__toString());
$this->assertEquals('a lamb', Str::toWords('a-lamb')->toString());
$this->assertEquals('a Camel', (string) Str::toWords('aCamel'));
}

$this->assertEquals('a dog', (string) Str::toWords('a dog'));
$this->assertEquals('a snake', Str::toWords('a_snake')->__toString());
$this->assertEquals('a lamb', Str::toWords('a-lamb')->toString());
$this->assertEquals('a Camel', (string) Str::toWords('aCamel'));
}

public function testUnprefixMethod (): void
{
$this->assertIsString(Str::unprefix('Instance', 'In'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->unprefix('In'));
public function testUnprefixMethod(): void
{
$this->assertIsString(Str::unprefix('Instance', 'In'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->unprefix('In'));

$this->assertEquals('path', Str::unprefix('path', '/'));
$this->assertEquals('path', Str::unprefix('/path', '/'));
}
$this->assertEquals('path', Str::unprefix('path', '/'));
$this->assertEquals('path', Str::unprefix('/path', '/'));
}

public function testUnsufffixMethod (): void
{
$this->assertIsString(Str::unsuffix('Instance', 'x'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->unsuffix('x'));
public function testUnsufffixMethod(): void
{
$this->assertIsString(Str::unsuffix('Instance', 'x'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->unsuffix('x'));

$this->assertEquals('path', Str::unsuffix('path', '/'));
$this->assertEquals('path', Str::unsuffix('path/', '/'));
}
$this->assertEquals('path', Str::unsuffix('path', '/'));
$this->assertEquals('path', Str::unsuffix('path/', '/'));
}

public function testUnwrapMethod(): void
{
$this->assertIsString(Str::unwrap('Instance', '/'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->unwrap('/'));
public function testUnwrapMethod(): void
{
$this->assertIsString(Str::unwrap('Instance', '/'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->unwrap('/'));

$this->assertEquals('path', Str::unwrap('path', '/'));
$this->assertEquals('path', Str::unwrap('path/', '/'));
$this->assertEquals('path', Str::unwrap('/path', '/'));
$this->assertEquals('path', Str::unwrap('/path/', '/'));
$this->assertEquals('path', Str::unwrap('path', '/x/', '/y/'));
$this->assertEquals('path', Str::unwrap('/x/path', '/x/', '/y/'));
$this->assertEquals('path', Str::unwrap('path/y/', '/x/', '/y/'));
$this->assertEquals('path', Str::unwrap('/x/path/y/', '/x/', '/y/'));
}
$this->assertEquals('path', Str::unwrap('path', '/'));
$this->assertEquals('path', Str::unwrap('path/', '/'));
$this->assertEquals('path', Str::unwrap('/path', '/'));
$this->assertEquals('path', Str::unwrap('/path/', '/'));
$this->assertEquals('path', Str::unwrap('path', '/x/', '/y/'));
$this->assertEquals('path', Str::unwrap('/x/path', '/x/', '/y/'));
$this->assertEquals('path', Str::unwrap('path/y/', '/x/', '/y/'));
$this->assertEquals('path', Str::unwrap('/x/path/y/', '/x/', '/y/'));
}

public function testWrapMethod (): void
{
$this->assertIsString(Str::wrap('Instance', '|'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->wrap('|'));
public function testWrapMethod(): void
{
$this->assertIsString(Str::wrap('Instance', '|'));
$this->assertInstanceOf(Stringable::class, Str::of('Instance')->wrap('|'));

$this->assertEquals('/path/', Str::wrap('path', '/'));
$this->assertEquals('/path/', Str::wrap('path/', '/'));
$this->assertEquals('/path/', Str::wrap('/path', '/'));
$this->assertEquals('/path/', Str::wrap('/path/', '/'));
$this->assertEquals('/x/path/y/', Str::wrap('path', '/x/', '/y/'));
$this->assertEquals('/x/path/y/', Str::wrap('/x/path', '/x/', '/y/'));
$this->assertEquals('/x/path/y/', Str::wrap('path/y/', '/x/', '/y/'));
}
$this->assertEquals('/path/', Str::wrap('path', '/'));
$this->assertEquals('/path/', Str::wrap('path/', '/'));
$this->assertEquals('/path/', Str::wrap('/path', '/'));
$this->assertEquals('/path/', Str::wrap('/path/', '/'));
$this->assertEquals('/x/path/y/', Str::wrap('path', '/x/', '/y/'));
$this->assertEquals('/x/path/y/', Str::wrap('/x/path', '/x/', '/y/'));
$this->assertEquals('/x/path/y/', Str::wrap('path/y/', '/x/', '/y/'));
}
}
20 changes: 10 additions & 10 deletions tests/WordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public function testInstanceOfCollection(): void
$this->assertInstanceOf(Collection::class, new Words([]));
}

public function testToStringMethodReturnsString(): void
{
public function testToStringMethodReturnsString(): void
{
// Default (space)
$words = new Words('Same');

Expand All @@ -26,7 +26,7 @@ public function testToStringMethodReturnsString(): void
// Custom glue
$multi = new Words('multiple-words');
$this->assertEquals('multiple/words', $multi->toString('/'));
}
}

public function testToStringMethodHandlesAcronymsCorrectly(): void
{
Expand All @@ -43,14 +43,14 @@ public function testToStringMethodHandlesDottedAcronymsCorrectly(): void
$this->assertEquals('html-for-noobs', $acronyms->of()->slug());
}

public function testOfMethodReturnsStringableInstance(): void
{
public function testOfMethodReturnsStringableInstance(): void
{
$this->assertInstanceOf(Stringable::class, (new Words('Stringable'))->of());
}
public function testToArrayMethodReturnsArray(): void
{

public function testToArrayMethodReturnsArray(): void
{
$this->assertIsArray((new Words(''))->toArray());
$this->assertIsArray((new Words([]))->toArray());
}
}
}
}

0 comments on commit a314614

Please sign in to comment.