Skip to content

Commit

Permalink
Using assertSame to make assertEquals restricted (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k authored Nov 29, 2022
1 parent d62bb25 commit ce1579e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion tests/Coduo/PHPHumanizer/Tests/CollectionHumanizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class CollectionHumanizerTest extends TestCase
*/
public function test_oxford_collections_humanizing($collection, $limit, $locale, $expectedResult) : void
{
$this->assertEquals($expectedResult, CollectionHumanizer::oxford($collection, $limit, $locale));
$this->assertSame($expectedResult, CollectionHumanizer::oxford($collection, $limit, $locale));
}

public function oxfordCollectionProvider()
Expand Down
8 changes: 4 additions & 4 deletions tests/Coduo/PHPHumanizer/Tests/DateTimeHumanizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ class DateTimeHumanizerTest extends TestCase
*/
public function test_humanize_difference_between_dates(string $firstDate, string $secondDate, string $expected, string $locale) : void
{
$this->assertEquals($expected, DateTimeHumanizer::difference(new \DateTime($firstDate), new \DateTime($secondDate), $locale));
$this->assertSame($expected, DateTimeHumanizer::difference(new \DateTime($firstDate), new \DateTime($secondDate), $locale));
}

/**
* @dataProvider humanizeDataProvider
*/
public function test_humanize_time_period(string $firstDate, string $secondDate, string $expected, string $locale) : void
{
$this->assertEquals($expected, DateTimeHumanizer::timePeriod(new TimePeriod(DateTime::fromString($firstDate), DateTime::fromString($secondDate)), $locale));
$this->assertSame($expected, DateTimeHumanizer::timePeriod(new TimePeriod(DateTime::fromString($firstDate), DateTime::fromString($secondDate)), $locale));
}

/**
* @dataProvider preciseDifferenceDataProvider
*/
public function test_humanize_precise_difference_between_dates(string $firstDate, string $secondDate, string $expected, string $locale) : void
{
$this->assertEquals($expected, DateTimeHumanizer::timePeriodPrecise(new TimePeriod(DateTime::fromString($firstDate), DateTime::fromString($secondDate)), $locale));
$this->assertSame($expected, DateTimeHumanizer::timePeriodPrecise(new TimePeriod(DateTime::fromString($firstDate), DateTime::fromString($secondDate)), $locale));
}

/**
* @dataProvider preciseDifferenceDataProvider
*/
public function test_humanize_time_period_precise(string $firstDate, string $secondDate, string $expected, string $locale) : void
{
$this->assertEquals($expected, DateTimeHumanizer::preciseDifference(new \DateTime($firstDate), new \DateTime($secondDate), $locale));
$this->assertSame($expected, DateTimeHumanizer::preciseDifference(new \DateTime($firstDate), new \DateTime($secondDate), $locale));
}

/**
Expand Down
40 changes: 20 additions & 20 deletions tests/Coduo/PHPHumanizer/Tests/NumberHumanizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class NumberHumanizerTest extends TestCase
*/
public function test_return_ordinal_suffix($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number));
$this->assertSame($expected, NumberHumanizer::ordinal($number));
}

/**
Expand All @@ -35,7 +35,7 @@ public function test_return_ordinal_suffix($expected, $number) : void
*/
public function test_return_ordinal_suffix_dutch($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number, 'nl'));
$this->assertSame($expected, NumberHumanizer::ordinal($number, 'nl'));
}

/**
Expand All @@ -46,7 +46,7 @@ public function test_return_ordinal_suffix_dutch($expected, $number) : void
*/
public function test_return_ordinal_suffix_indonesian($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number, 'id'));
$this->assertSame($expected, NumberHumanizer::ordinal($number, 'id'));
}

/**
Expand All @@ -57,7 +57,7 @@ public function test_return_ordinal_suffix_indonesian($expected, $number) : void
*/
public function test_return_ordinal_suffix_spanish($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number, 'es'));
$this->assertSame($expected, NumberHumanizer::ordinal($number, 'es'));
}

/**
Expand All @@ -68,7 +68,7 @@ public function test_return_ordinal_suffix_spanish($expected, $number) : void
*/
public function test_return_ordinal_suffix_italian($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number, 'it'));
$this->assertSame($expected, NumberHumanizer::ordinal($number, 'it'));
}

/**
Expand All @@ -79,7 +79,7 @@ public function test_return_ordinal_suffix_italian($expected, $number) : void
*/
public function test_return_ordinal_suffix_german($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number, 'de'));
$this->assertSame($expected, NumberHumanizer::ordinal($number, 'de'));
}

/**
Expand All @@ -90,7 +90,7 @@ public function test_return_ordinal_suffix_german($expected, $number) : void
*/
public function test_return_ordinal_suffix_french($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinal($number, 'fr'));
$this->assertSame($expected, NumberHumanizer::ordinal($number, 'fr'));
}

/**
Expand All @@ -102,7 +102,7 @@ public function test_return_ordinal_suffix_french($expected, $number) : void
*/
public function test_ordinalize_numbers($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number));
$this->assertSame($expected, NumberHumanizer::ordinalize($number));
}

/**
Expand All @@ -114,7 +114,7 @@ public function test_ordinalize_numbers($expected, $number) : void
*/
public function test_ordinalize_numbers_dutch($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'nl'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'nl'));
}

/**
Expand All @@ -126,7 +126,7 @@ public function test_ordinalize_numbers_dutch($expected, $number) : void
*/
public function test_ordinalize_numbers_indonesian($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'id'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'id'));
}

/**
Expand All @@ -137,7 +137,7 @@ public function test_ordinalize_numbers_indonesian($expected, $number) : void
*/
public function test_ordinalize_numbers_portuguese($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'pt'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'pt'));
}

/**
Expand All @@ -148,7 +148,7 @@ public function test_ordinalize_numbers_portuguese($expected, $number) : void
*/
public function test_ordinalize_numbers_spanish($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'es'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'es'));
}

/**
Expand All @@ -159,7 +159,7 @@ public function test_ordinalize_numbers_spanish($expected, $number) : void
*/
public function test_ordinalize_numbers_italian($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'it'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'it'));
}

/**
Expand All @@ -170,7 +170,7 @@ public function test_ordinalize_numbers_italian($expected, $number) : void
*/
public function test_ordinalize_numbers_german($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'de'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'de'));
}

/**
Expand All @@ -181,7 +181,7 @@ public function test_ordinalize_numbers_german($expected, $number) : void
*/
public function test_ordinalize_numbers_french($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::ordinalize($number, 'fr'));
$this->assertSame($expected, NumberHumanizer::ordinalize($number, 'fr'));
}

/**
Expand All @@ -193,7 +193,7 @@ public function test_ordinalize_numbers_french($expected, $number) : void
*/
public function test_convert_number_to_string_with_binary_suffix($expected, $number, $locale = 'en') : void
{
$this->assertEquals($expected, NumberHumanizer::binarySuffix($number, $locale));
$this->assertSame($expected, NumberHumanizer::binarySuffix($number, $locale));
}

/**
Expand All @@ -206,7 +206,7 @@ public function test_convert_number_to_string_with_binary_suffix($expected, $num
*/
public function test_convert_number_to_string_with_precise_binary_suffix($expected, $number, $precision, $locale = 'en') : void
{
$this->assertEquals($expected, NumberHumanizer::preciseBinarySuffix($number, $precision, $locale));
$this->assertSame($expected, NumberHumanizer::preciseBinarySuffix($number, $precision, $locale));
}

public function test_statically_throw_exception_when_converting_to_string_with_precise_binary_suffix_negative_precision() : void
Expand All @@ -232,7 +232,7 @@ public function test_statically_throw_exception_when_converting_to_string_with_p
*/
public function test_convert_number_to_string_with_metric_suffix($expected, $number, $locale = 'en') : void
{
$this->assertEquals($expected, NumberHumanizer::metricSuffix($number, $locale));
$this->assertSame($expected, NumberHumanizer::metricSuffix($number, $locale));
}

public function test_statically_throw_exception_when_converting_to_string_with_metric_suffix_non_numeric_values() : void
Expand All @@ -250,7 +250,7 @@ public function test_statically_throw_exception_when_converting_to_string_with_m
*/
public function test_converts_numbers_to_roman($expected, $number) : void
{
$this->assertEquals($expected, NumberHumanizer::toRoman($number));
$this->assertSame($expected, NumberHumanizer::toRoman($number));
}

/**
Expand All @@ -261,7 +261,7 @@ public function test_converts_numbers_to_roman($expected, $number) : void
*/
public function test_convert_roman_numbers_to_arabic($number, $expected) : void
{
$this->assertEquals($expected, NumberHumanizer::fromRoman($number));
$this->assertSame($expected, NumberHumanizer::fromRoman($number));
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/Coduo/PHPHumanizer/Tests/StringHumanizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class StringHumanizerTest extends TestCase
*/
public function test_humanize_strings($input, $expected, $capitalize, $separator, array $forbiddenWords) : void
{
$this->assertEquals($expected, StringHumanizer::humanize($input, $capitalize, $separator, $forbiddenWords));
$this->assertSame($expected, StringHumanizer::humanize($input, $capitalize, $separator, $forbiddenWords));
}

/**
Expand All @@ -40,7 +40,7 @@ public function test_humanize_strings($input, $expected, $capitalize, $separator
*/
public function test_truncate_string_to_word_closest_to_a_certain_number_of_characters($text, $expected, $charactersCount, $append = '') : void
{
$this->assertEquals($expected, StringHumanizer::truncate($text, $charactersCount, $append));
$this->assertSame($expected, StringHumanizer::truncate($text, $charactersCount, $append));
}

/**
Expand All @@ -54,7 +54,7 @@ public function test_truncate_string_to_word_closest_to_a_certain_number_of_char
*/
public function test_truncate_string_to_word_closest_to_a_certain_number_of_characters_with_html_tags($text, $charactersCount, $allowedTags, $expected, $append = '') : void
{
$this->assertEquals($expected, StringHumanizer::truncateHtml($text, $charactersCount, $allowedTags, $append));
$this->assertSame($expected, StringHumanizer::truncateHtml($text, $charactersCount, $allowedTags, $append));
}

/**
Expand All @@ -65,7 +65,7 @@ public function test_truncate_string_to_word_closest_to_a_certain_number_of_char
*/
public function test_remove_all_shortcodes_from_text($text, $expected) : void
{
$this->assertEquals($expected, StringHumanizer::removeShortcodes($text));
$this->assertSame($expected, StringHumanizer::removeShortcodes($text));
}

/**
Expand All @@ -76,7 +76,7 @@ public function test_remove_all_shortcodes_from_text($text, $expected) : void
*/
public function test_remove_only_shortcode_tags_from_text($text, $expected) : void
{
$this->assertEquals($expected, StringHumanizer::removeShortcodeTags($text));
$this->assertSame($expected, StringHumanizer::removeShortcodeTags($text));
}

public function removeAllShortcodesProvider()
Expand Down

0 comments on commit ce1579e

Please sign in to comment.