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

Fix/add missing tests string functions #1491

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions src/core/etl/tests/Flow/ETL/Tests/Unit/Function/IndexOfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ public function test_index_of() : void
);
}

public function test_needle_null_index_of_returns_false() : void
{
self::assertFalse(
ref('str')->indexOf(ref('needle'))->eval(
row(
str_entry('str', 'x'),
str_entry('needle', null)
)
)
);
}

public function test_returns_method_returns_string_int() : void
{
$indexOf = new IndexOf('Abba', 'b', offset: 3);
Expand All @@ -51,4 +63,15 @@ public function test_returns_method_returns_string_int() : void

self::assertTrue($returnType->isEqual(type_int()));
}

public function test_string_null_index_of_returns_false() : void
{
self::assertFalse(
ref('str')->indexOf('x')->eval(
row(
str_entry('str', null),
)
)
);
}
}
11 changes: 11 additions & 0 deletions src/core/etl/tests/Flow/ETL/Tests/Unit/Function/IsUtf8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@

final class IsUtf8Test extends FlowTestCase
{
public function test_is_utf8_returns_null() : void
{
self::assertNull(
ref('str')->isUtf8()->eval(
row(
str_entry('str', null),
)
)
);
}

public function test_is_utf_8() : void
{
self::assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

use function Flow\ETL\DSL\row;
use function Flow\ETL\DSL\{ref, str_entry, type_string};
use Flow\ETL\Function\StringTitle;
use Flow\ETL\Function\{StringAfter};
use Flow\ETL\PHP\Type\Type;
use Flow\ETL\Tests\FlowTestCase;

final class StringAfterTest extends FlowTestCase
{
public function test_returns_method_returns_string_type() : void
{
$stringTitleFunction = new StringTitle('str');
$returnType = $stringTitleFunction->returns();
$stringAfterFunction = new StringAfter('test', 'e');
$returnType = $stringAfterFunction->returns();

self::assertInstanceOf(Type::class, $returnType);

Expand Down Expand Up @@ -57,4 +57,15 @@ public function test_string_after_including_needle() : void
)
);
}

public function test_string_after_returns_null() : void
{
self::assertNull(
ref('str')->stringAfter('x')->eval(
row(
str_entry('str', null),
)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
namespace Flow\ETL\Tests\Unit\Function;

use function Flow\ETL\DSL\row;
use function Flow\ETL\DSL\{ref, str_entry};
use function Flow\ETL\DSL\{ref, str_entry, type_string};
use Flow\ETL\Function\StringFold;
use Flow\ETL\PHP\Type\Type;
use Flow\ETL\Tests\FlowTestCase;

final class StringFoldTest extends FlowTestCase
{
public function test_returns_method_returns_string_type() : void
{
$stringFoldedFunction = new StringFold('str');
$returnType = $stringFoldedFunction->returns();

self::assertInstanceOf(Type::class, $returnType);

self::assertTrue($returnType->isEqual(type_string()));
}

public function test_string_folded() : void
{
self::assertSame(
Expand All @@ -19,4 +31,15 @@ public function test_string_folded() : void
)
);
}

public function test_string_folded_returns_null() : void
{
self::assertNull(
ref('str')->stringFold()->eval(
row(
str_entry('str', null),
)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public function test_string_style_lower() : void
);
}

public function test_string_style_returns_null() : void
{
self::assertNull(
ref('str')->stringStyle(StringStyles::LOWER)->eval(
row(
str_entry('str', null),
)
)
);
}

public function test_string_style_snake() : void
{
self::assertSame(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,15 @@ public function test_string_title_allwords() : void
)
);
}

public function test_string_title_returns_null() : void
{
self::assertNull(
ref('str')->stringTitle()->eval(
row(
str_entry('str', null),
)
)
);
}
}