From 72b02fbcc4558988d7c1203dd4d07133f73453bd Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 12:40:21 +0100 Subject: [PATCH 1/9] Updating PHP CS Fixer to v2, as v1 is no longer maintained --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2ec5cd3..f9268ed 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "patchwork/utf8": "^1.2" }, "require-dev": { - "fabpot/php-cs-fixer": "^1.10", + "friendsofphp/php-cs-fixer": "^2.6.0", "phpunit/phpunit": "^4.8" }, "autoload": { From 551be95951ff1f9cd97d8587dbf8264b2fccd83c Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 12:42:51 +0100 Subject: [PATCH 2/9] PHP 5.4 and 5.5 are deprecated, so removing from the CI tests --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 405ed57..3ce2d36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,6 @@ sudo: false # Setup build matrix language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - hhvm From cb0ce05dfc1bf992070adc85eff57e33c8aca07e Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 12:49:32 +0100 Subject: [PATCH 3/9] Updates .php_cs as per FriendsOfPHP/PHP-CS-Fixer/blob/2.6/.php_cs.dist --- .php_cs | 92 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/.php_cs b/.php_cs index 8076e18..87e03df 100644 --- a/.php_cs +++ b/.php_cs @@ -1,34 +1,72 @@ in(['config', 'src', 'tests']); -$header = <<< EOF -This file is part of Underscore.php +$header = <<<'EOF' +This file is part of PHP CS Fixer. -(c) Maxime Fabre +(c) Fabien Potencier + Dariusz Rumiński -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. +This source file is subject to the MIT license that is bundled +with this source code in the file LICENSE. EOF; -HeaderCommentFixer::setHeader($header); +$config = PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + '@PHP56Migration' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + 'align_multiline_comment' => true, + 'array_syntax' => ['syntax' => 'short'], + 'blank_line_before_statement' => true, + 'combine_consecutive_issets' => true, + 'combine_consecutive_unsets' => true, + // one should use PHPUnit methods to set up expected exception instead of annotations + 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']], + 'header_comment' => ['header' => $header], + 'heredoc_to_nowdoc' => true, + 'list_syntax' => ['syntax' => 'long'], + 'method_argument_space' => ['ensure_fully_multiline' => true], + 'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], + 'no_homoglyph_names' => true, + 'no_null_property_initialization' => true, + 'no_short_echo_tag' => true, + 'no_superfluous_elseif' => true, + 'no_unneeded_curly_braces' => true, + 'no_unneeded_final_method' => true, + 'no_unreachable_default_argument_value' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'php_unit_strict' => true, + 'php_unit_test_class_requires_covers' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_order' => true, + 'phpdoc_types_order' => true, + 'semicolon_after_instruction' => true, + 'single_line_comment_style' => true, + 'strict_comparison' => true, + 'strict_param' => true, + 'yoda_style' => true, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('tests/Fixtures') + ->in(__DIR__) + ) +; -return Config::create() - ->level(FixerInterface::SYMFONY_LEVEL) - ->fixers([ - 'ereg_to_preg', - 'header_comment', - 'multiline_spaces_before_semicolon', - 'ordered_use', - 'php4_constructor', - 'phpdoc_order', - 'short_array_syntax', - 'short_echo_tag', - 'strict', - 'strict_param', - ]) - ->setUsingCache(true) - ->finder($finder); +// special handling of fabbot.io service if it's using too old PHP CS Fixer version +try { + PhpCsFixer\FixerFactory::create() + ->registerBuiltInFixers() + ->registerCustomFixers($config->getCustomFixers()) + ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules())); +} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) { + $config->setRules([]); +} catch (UnexpectedValueException $e) { + $config->setRules([]); +} + +return $config; From bf076d8e6f14599426ac76174da80c07c1e45e4d Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 14:30:10 +0100 Subject: [PATCH 4/9] Disables a warning if xdebug is being used --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3ce2d36..f401ecf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,15 @@ php: - hhvm env: + global: + - COMPOSER_DISABLE_XDEBUG_WARN=1 matrix: - PREFER_LOWEST="--prefer-lowest" - PREFER_LOWEST="" # Dependencies before_install: + - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi - composer self-update install: From b591d0b8fd165b442fdab826af00d1173caa9e41 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 14:38:43 +0100 Subject: [PATCH 5/9] Removes deprecated option dev, as Dev packages are installed by default now --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f401ecf..428bc20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_install: - composer self-update install: - - travis_retry composer update --no-interaction --prefer-source --dev $PREFER_LOWEST + - travis_retry composer update --no-interaction --prefer-source $PREFER_LOWEST script: composer test From 2348ac4c0dd6d0b026d6bb4f99f08a06e6700bea Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 14:44:06 +0100 Subject: [PATCH 6/9] Removes conflicting hhvm --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 428bc20..077d745 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ language: php php: - 5.6 - 7.0 - - hhvm env: global: From dd34c120f9661f05cc322a15e64202522132d5b5 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 14:45:55 +0100 Subject: [PATCH 7/9] Adds --verbose for php-cs-fixer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f9268ed..984feb9 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ } }, "scripts": { - "test": ["php-cs-fixer fix --dry-run", "phpunit --verbose"], + "test": ["php-cs-fixer fix --dry-run --verbose", "phpunit --verbose"], "lint": "php-cs-fixer fix" } } From b00d55e7666db85302de8f990586b5f0d23fcde2 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 14:58:24 +0100 Subject: [PATCH 8/9] Disables adding header_comment --- .php_cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.php_cs b/.php_cs index 87e03df..71bfa8f 100644 --- a/.php_cs +++ b/.php_cs @@ -1,15 +1,5 @@ - Dariusz Rumiński - -This source file is subject to the MIT license that is bundled -with this source code in the file LICENSE. -EOF; - $config = PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules([ @@ -23,7 +13,6 @@ $config = PhpCsFixer\Config::create() 'combine_consecutive_unsets' => true, // one should use PHPUnit methods to set up expected exception instead of annotations 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']], - 'header_comment' => ['header' => $header], 'heredoc_to_nowdoc' => true, 'list_syntax' => ['syntax' => 'long'], 'method_argument_space' => ['ensure_fully_multiline' => true], From 9a99919e6728a54a970e0bae205b04d510f9d913 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 25 Sep 2017 15:01:03 +0100 Subject: [PATCH 9/9] Code fixed by php-cs-fixer --- config/config.php | 2 - helpers.php | 20 ++-- src/Dispatch.php | 3 +- src/Methods/ArraysMethods.php | 82 +++++++++++--- src/Methods/CollectionMethods.php | 90 ++++++++++----- src/Methods/FunctionsMethods.php | 13 +-- src/Methods/NumberMethods.php | 10 ++ src/Methods/ObjectMethods.php | 5 + src/Methods/StringsMethods.php | 105 ++++++++++------- src/Parse.php | 13 ++- src/Traits/Repository.php | 134 ++++++++++++---------- src/Types/Strings.php | 2 +- tests/DispatchTest.php | 9 +- tests/MethodTest.php | 21 ++-- tests/ParseTest.php | 25 +++-- tests/Types/ArraysTest.php | 180 +++++++++++++++--------------- tests/Types/FunctionsTest.php | 19 ++-- tests/Types/NumberTest.php | 19 ++-- tests/Types/ObjectTest.php | 57 +++++----- tests/Types/StringTest.php | 95 +++++++++------- tests/UnderscoreTest.php | 37 +++--- 21 files changed, 562 insertions(+), 379 deletions(-) diff --git a/config/config.php b/config/config.php index 25b8313..63ae09a 100644 --- a/config/config.php +++ b/config/config.php @@ -10,7 +10,6 @@ */ return [ - // The alias Underscore will be mapped to 'alias' => 'Underscore', @@ -21,5 +20,4 @@ 'select' => 'filter', 'sortBy' => 'sort', ], - ]; diff --git a/helpers.php b/helpers.php index ae1fe2c..ab81b58 100644 --- a/helpers.php +++ b/helpers.php @@ -1,19 +1,20 @@ = $canBeCalledTimes) { return false; - } else { - ++FunctionsMethods::$canBeCalledTimes[$signature]; } + ++FunctionsMethods::$canBeCalledTimes[$signature]; return call_user_func_array($function, $arguments); }; @@ -101,7 +100,6 @@ public static function after($function, $times) // Create a closure that check if the function was already called return function () use ($function, $times, $unique) { - // Generate unique hash of the function $arguments = func_get_args(); $signature = FunctionsMethods::getSignature($unique, $function, $arguments); @@ -132,7 +130,6 @@ public static function cache($function) $unique = mt_rand(); return function () use ($function, $unique) { - // Generate unique hash of the function $arguments = func_get_args(); $signature = FunctionsMethods::getSignature($unique, $function, $arguments); @@ -161,7 +158,6 @@ public static function throttle($function, $ms) $unique = mt_rand(); return function () use ($function, $ms, $unique) { - // Generate unique hash of the function $arguments = func_get_args(); $signature = FunctionsMethods::getSignature($unique, $function, $arguments); @@ -200,7 +196,7 @@ public static function partial(callable $func) $position = 0; for ($i = 0, $len = count($boundArgs); $i < $len; ++$i) { - $args[] = $boundArgs[$i] === null ? $calledArgs[$position++] : $boundArgs[$i]; + $args[] = null === $boundArgs[$i] ? $calledArgs[$position++] : $boundArgs[$i]; } return call_user_func_array($func, array_merge($args, array_slice($calledArgs, $position))); @@ -240,6 +236,7 @@ public static function hasBeenCalledTimes($unique) * * @param Closure $function The function * @param array $arguments Its arguments + * @param mixed $unique * * @return string The unique id */ diff --git a/src/Methods/NumberMethods.php b/src/Methods/NumberMethods.php index 918729d..bc7b585 100644 --- a/src/Methods/NumberMethods.php +++ b/src/Methods/NumberMethods.php @@ -18,6 +18,10 @@ class NumberMethods { /** * Add 0 padding to an integer. + * + * @param mixed $number + * @param mixed $padding + * @param mixed $direction */ public static function padding($number, $padding = 1, $direction = STR_PAD_BOTH) { @@ -26,6 +30,9 @@ public static function padding($number, $padding = 1, $direction = STR_PAD_BOTH) /** * Add 0 padding on the left of an integer. + * + * @param mixed $number + * @param mixed $padding */ public static function paddingLeft($number, $padding = 1) { @@ -34,6 +41,9 @@ public static function paddingLeft($number, $padding = 1) /** * Add 0 padding on the right of an integer. + * + * @param mixed $number + * @param mixed $padding */ public static function paddingRight($number, $padding = 1) { diff --git a/src/Methods/ObjectMethods.php b/src/Methods/ObjectMethods.php index a1b8f1c..af9d00b 100644 --- a/src/Methods/ObjectMethods.php +++ b/src/Methods/ObjectMethods.php @@ -18,6 +18,8 @@ class ObjectMethods extends CollectionMethods { /** * Get all methods from an object. + * + * @param mixed $object */ public static function methods($object) { @@ -26,6 +28,9 @@ public static function methods($object) /** * Unpack an object's properties. + * + * @param mixed $object + * @param null|mixed $attribute */ public static function unpack($object, $attribute = null) { diff --git a/src/Methods/StringsMethods.php b/src/Methods/StringsMethods.php index 5d5ef6d..d0ab34e 100644 --- a/src/Methods/StringsMethods.php +++ b/src/Methods/StringsMethods.php @@ -37,10 +37,10 @@ class StringsMethods */ public static function accord($count, $many, $one, $zero = null) { - if ($count === 1) { + if (1 === $count) { $output = $one; } else { - if ($count === 0 and !empty($zero)) { + if (0 === $count and !empty($zero)) { $output = $zero; } else { $output = $many; @@ -66,7 +66,7 @@ public static function random($length = 16) if (function_exists('openssl_random_pseudo_bytes')) { $bytes = openssl_random_pseudo_bytes($length * 2); - if ($bytes === false) { + if (false === $bytes) { throw new RuntimeException('Unable to generate random string.'); } @@ -120,7 +120,7 @@ public static function randomStrings($words, $length = 10) * Determine if a given string ends with a given substring. * * @param string $haystack - * @param string|array $needles + * @param array|string $needles * * @return bool * @@ -140,38 +140,44 @@ public static function endsWith($haystack, $needles) /** * Check if a string is an IP. * + * @param mixed $string + * * @return bool */ public static function isIp($string) { - return filter_var($string, FILTER_VALIDATE_IP) !== false; + return false !== filter_var($string, FILTER_VALIDATE_IP); } /** * Check if a string is an email. * + * @param mixed $string + * * @return bool */ public static function isEmail($string) { - return filter_var($string, FILTER_VALIDATE_EMAIL) !== false; + return false !== filter_var($string, FILTER_VALIDATE_EMAIL); } /** * Check if a string is an url. * + * @param mixed $string + * * @return bool */ public static function isUrl($string) { - return filter_var($string, FILTER_VALIDATE_URL) !== false; + return false !== filter_var($string, FILTER_VALIDATE_URL); } /** * Determine if a given string starts with a given substring. * * @param string $haystack - * @param string|array $needles + * @param array|string $needles * * @return bool * @@ -180,7 +186,7 @@ public static function isUrl($string) public static function startsWith($haystack, $needles) { foreach ((array) $needles as $needle) { - if ($needle !== '' && strpos($haystack, $needle) === 0) { + if ('' !== $needle && 0 === strpos($haystack, $needle)) { return true; } } @@ -233,11 +239,14 @@ public static function find($string, $needle, $caseSensitive = false, $absolute // If string found $pos = strpos($string, $needle); - return !($pos === false); + return !(false === $pos); } /** * Slice a string with another string. + * + * @param mixed $string + * @param mixed $slice */ public static function slice($string, $slice) { @@ -249,6 +258,9 @@ public static function slice($string, $slice) /** * Slice a string from a certain point. + * + * @param mixed $string + * @param mixed $slice */ public static function sliceFrom($string, $slice) { @@ -259,6 +271,9 @@ public static function sliceFrom($string, $slice) /** * Slice a string up to a certain point. + * + * @param mixed $string + * @param mixed $slice */ public static function sliceTo($string, $slice) { @@ -333,6 +348,9 @@ public static function limit($value, $limit = 100, $end = '...') /** * Remove part of a string. + * + * @param mixed $string + * @param mixed $remove */ public static function remove($string, $remove) { @@ -346,6 +364,10 @@ public static function remove($string, $remove) /** * Correct arguments order for str_replace. + * + * @param mixed $string + * @param mixed $replace + * @param mixed $with */ public static function replace($string, $replace, $with) { @@ -372,36 +394,11 @@ public static function toggle($string, $first, $second, $loose = false) return $string === $first ? $second : $first; } - /** - * Generate a URL friendly "slug" from a given string. - * - * @param string $title - * @param string $separator - * - * @return string - * - * @author Taylor Otwell - */ - protected static function slug($title, $separator = '-') - { - $title = Utf8::toAscii($title); - - // Convert all dashes/underscores into separator - $flip = $separator === '-' ? '_' : '-'; - - $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); - - // Remove all characters that are not the separator, letters, numbers, or whitespace. - $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); - - // Replace all separator characters and whitespace by a single separator - $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); - - return trim($title, $separator); - } - /** * Slugifies a string. + * + * @param mixed $string + * @param mixed $separator */ public static function slugify($string, $separator = '-') { @@ -412,6 +409,10 @@ public static function slugify($string, $separator = '-') /** * Explode a string into an array. + * + * @param mixed $string + * @param mixed $with + * @param null|mixed $limit */ public static function explode($string, $with, $limit = null) { @@ -546,4 +547,32 @@ public static function toCamelCase($string) { return Inflector::camelize($string); } + + /** + * Generate a URL friendly "slug" from a given string. + * + * @param string $title + * @param string $separator + * + * @return string + * + * @author Taylor Otwell + */ + protected static function slug($title, $separator = '-') + { + $title = Utf8::toAscii($title); + + // Convert all dashes/underscores into separator + $flip = '-' === $separator ? '_' : '-'; + + $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); + + // Remove all characters that are not the separator, letters, numbers, or whitespace. + $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); + + // Replace all separator characters and whitespace by a single separator + $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); + + return trim($title, $separator); + } } diff --git a/src/Parse.php b/src/Parse.php index 9aaf762..b91c1c8 100644 --- a/src/Parse.php +++ b/src/Parse.php @@ -139,6 +139,7 @@ public static function toCSV($data, $delimiter = ';', $exportHeaders = false) // If single column if (!is_array($row)) { $csv[] = '"'.$header.'"'.$delimiter.'"'.$row.'"'; + continue; } @@ -160,7 +161,7 @@ public static function toCSV($data, $delimiter = ';', $exportHeaders = false) /** * Converts data to an array. * - * @param string|object $data + * @param object|string $data * * @return array */ @@ -194,7 +195,7 @@ public static function toString($data) /** * Converts data to an integer. * - * @param array|string|object $data + * @param array|object|string $data * * @return int */ @@ -216,7 +217,7 @@ public static function toInteger($data) /** * Converts data to a boolean. * - * @param array|sring|object $data + * @param array|object|sring $data * * @return bool */ @@ -255,11 +256,11 @@ public static function explodeWith($string, array $delimiters) foreach ($delimiters as $delimiter) { $array = explode($delimiter, $string); - if (count($array) === 1) { + if (1 === count($array)) { continue; - } else { - return $array; } + + return $array; } return $array; diff --git a/src/Traits/Repository.php b/src/Traits/Repository.php index ea1f58f..2d69de3 100644 --- a/src/Traits/Repository.php +++ b/src/Traits/Repository.php @@ -77,24 +77,10 @@ public function __toString() return Parse::toString($this->subject); } - /** - * Create a new Repository. - */ - public static function create() - { - return new static(); - } - - /** - * Create a new Repository from a subject. - */ - public static function from($subject) - { - return new static($subject); - } - /** * Get a key from the subject. + * + * @param mixed $key */ public function __get($key) { @@ -103,53 +89,13 @@ public function __get($key) /** * Set a value on the subject. - */ - public function __set($key, $value) - { - $this->subject = ArraysMethods::set($this->subject, $key, $value); - } - - /** - * Check if the subject is empty. - * - * @return bool - */ - public function isEmpty() - { - return empty($this->subject); - } - - /** - * Replace the Subject while maintaining chain. * + * @param mixed $key * @param mixed $value */ - public function setSubject($value) - { - $this->subject = $value; - - return $this; - } - - /** - * Get the subject from the object. - * - * @return mixed - */ - public function obtain() - { - return $this->subject; - } - - /** - * Extend the class with a custom function. - * - * @param string $method The macro's name - * @param callable $closure The macro - */ - public static function extend($method, $closure) + public function __set($key, $value) { - static::$macros[get_called_class()][$method] = $closure; + $this->subject = ArraysMethods::set($this->subject, $key, $value); } //////////////////////////////////////////////////////////////////// @@ -158,6 +104,9 @@ public static function extend($method, $closure) /** * Catch aliases and reroute them to the right methods. + * + * @param mixed $method + * @param mixed $parameters */ public static function __callStatic($method, $parameters) { @@ -195,6 +144,9 @@ public static function __callStatic($method, $parameters) /** * Allow the chained calling of methods. + * + * @param mixed $method + * @param mixed $arguments */ public function __call($method, $arguments) { @@ -215,13 +167,73 @@ public function __call($method, $arguments) // If the method is a breaker, return just the result if (Method::isBreaker($method)) { return $result; - } else { - $this->subject = $result; } + $this->subject = $result; + + return $this; + } + + /** + * Create a new Repository. + */ + public static function create() + { + return new static(); + } + + /** + * Create a new Repository from a subject. + * + * @param mixed $subject + */ + public static function from($subject) + { + return new static($subject); + } + + /** + * Check if the subject is empty. + * + * @return bool + */ + public function isEmpty() + { + return empty($this->subject); + } + + /** + * Replace the Subject while maintaining chain. + * + * @param mixed $value + */ + public function setSubject($value) + { + $this->subject = $value; return $this; } + /** + * Get the subject from the object. + * + * @return mixed + */ + public function obtain() + { + return $this->subject; + } + + /** + * Extend the class with a custom function. + * + * @param string $method The macro's name + * @param callable $closure The macro + */ + public static function extend($method, $closure) + { + static::$macros[get_called_class()][$method] = $closure; + } + //////////////////////////////////////////////////////////////////// ///////////////////////////// HELPERS ////////////////////////////// //////////////////////////////////////////////////////////////////// diff --git a/src/Types/Strings.php b/src/Types/Strings.php index 0376a0e..cb9fb91 100644 --- a/src/Types/Strings.php +++ b/src/Types/Strings.php @@ -16,7 +16,7 @@ /** * Strings repository. - + * * *@mixin StringsMethods */ diff --git a/tests/DispatchTest.php b/tests/DispatchTest.php index b20e2ab..cfa80f2 100644 --- a/tests/DispatchTest.php +++ b/tests/DispatchTest.php @@ -13,6 +13,9 @@ use StdClass; +/** + * @coversNothing + */ class DispatchTest extends UnderscoreTestCase { // Data providers ------------------------------------------------ / @@ -29,7 +32,6 @@ public function provideTypes() [new StdClass(), 'Object'], [ function () { - return; }, 'Functions', ], @@ -39,12 +41,15 @@ function () { /** * @dataProvider provideTypes + * + * @param mixed $subject + * @param mixed $expected */ public function testCanGetClassFromType($subject, $expected) { $dispatch = Dispatch::toClass($subject); - $this->assertEquals('Underscore\Types\\'.$expected, $dispatch); + $this->assertSame('Underscore\Types\\'.$expected, $dispatch); } public function testCanThrowExceptionAtUnknownTypes() diff --git a/tests/MethodTest.php b/tests/MethodTest.php index 4bb35dd..697ced3 100644 --- a/tests/MethodTest.php +++ b/tests/MethodTest.php @@ -14,6 +14,9 @@ use Underscore\Types\Arrays; use Underscore\Types\Strings; +/** + * @coversNothing + */ class MethodTest extends UnderscoreTestCase { public function testThrowsErrorIfIncorrectMethod() @@ -28,13 +31,13 @@ public function testHasAccessToOriginalPhpFunctions() $array = Arrays::from($this->array); $array = $array->intersect(['foo' => 'bar', 'kal' => 'mon']); - $this->assertEquals(['foo' => 'bar'], $array->obtain()); + $this->assertSame(['foo' => 'bar'], $array->obtain()); $string = Strings::repeat('foo', 2); - $this->assertEquals('foofoo', $string); + $this->assertSame('foofoo', $string); $string = Strings::from(' foo ')->trim(); - $this->assertEquals('foo', $string->obtain()); + $this->assertSame('foo', $string->obtain()); } public function testCantChainCertainMethods() @@ -48,27 +51,29 @@ public function testCanGetMethodsFromType() { $method = Method::getMethodsFromType('\Underscore\Types\Arrays'); - $this->assertEquals('\Underscore\Methods\ArraysMethods', $method); + $this->assertSame('\Underscore\Methods\ArraysMethods', $method); } public function testCanGetAliasesOfFunctions() { $method = Method::getAliasOf('select'); - $this->assertEquals('filter', $method); + $this->assertSame('filter', $method); } public function testCanFindMethodsInClasses() { $method = Method::findInClasses('\Underscore\Underscore', 'range'); - $this->assertEquals('\Underscore\Types\\Arrays', $method); + $this->assertSame('\Underscore\Types\\Arrays', $method); } public function testCanThrowExceptionAtUnknownMethods() { - $this->setExpectedException('BadMethodCallException', - 'The method Underscore\Types\Arrays::fuck does not exist'); + $this->setExpectedException( + 'BadMethodCallException', + 'The method Underscore\Types\Arrays::fuck does not exist' + ); $test = Arrays::fuck($this); } diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 161c476..0b43668 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -13,6 +13,9 @@ use Underscore\Dummies\DummyDefault; +/** + * @coversNothing + */ class ParseTest extends UnderscoreTestCase { //////////////////////////////////////////////////////////////////// @@ -52,7 +55,7 @@ public function testCanCreateCsvFiles() $csv = Parse::toCSV($this->arrayMulti); $matcher = '"bar";"ter"'.PHP_EOL.'"bar";"ter"'.PHP_EOL.'"foo";"ter"'; - $this->assertEquals($matcher, $csv); + $this->assertSame($matcher, $csv); } public function testCanUseCustomCsvDelimiter() @@ -60,7 +63,7 @@ public function testCanUseCustomCsvDelimiter() $csv = Parse::toCSV($this->arrayMulti, ','); $matcher = '"bar","ter"'.PHP_EOL.'"bar","ter"'.PHP_EOL.'"foo","ter"'; - $this->assertEquals($matcher, $csv); + $this->assertSame($matcher, $csv); } public function testCanOutputCsvHeaders() @@ -68,7 +71,7 @@ public function testCanOutputCsvHeaders() $csv = Parse::toCSV($this->arrayMulti, ',', true); $matcher = 'foo,bis'.PHP_EOL.'"bar","ter"'.PHP_EOL.'"bar","ter"'.PHP_EOL.'"foo","ter"'; - $this->assertEquals($matcher, $csv); + $this->assertSame($matcher, $csv); } public function testCanConvertToJson() @@ -76,7 +79,7 @@ public function testCanConvertToJson() $json = Parse::toJSON($this->arrayMulti); $matcher = '[{"foo":"bar","bis":"ter"},{"foo":"bar","bis":"ter"},{"bar":"foo","bis":"ter"}]'; - $this->assertEquals($matcher, $json); + $this->assertSame($matcher, $json); } public function testCanParseJson() @@ -84,7 +87,7 @@ public function testCanParseJson() $json = Parse::toJSON($this->arrayMulti); $array = Parse::fromJSON($json); - $this->assertEquals($this->arrayMulti, $array); + $this->assertSame($this->arrayMulti, $array); } public function testCanParseXML() @@ -92,7 +95,7 @@ public function testCanParseXML() $array = Parse::fromXML('
foobar
'); $matcher = ['name' => 'foo', 'content' => 'bar']; - $this->assertEquals($matcher, $array); + $this->assertSame($matcher, $array); } public function testCanParseCSV() @@ -100,7 +103,7 @@ public function testCanParseCSV() $array = Parse::fromCSV("foo;bar;bis\nbar\tfoo\tter"); $results = [['foo', 'bar', 'bis'], ['bar', 'foo', 'ter']]; - $this->assertEquals($results, $array); + $this->assertSame($results, $array); } public function testCanParseCSVWithHeaders($value = '') @@ -108,7 +111,7 @@ public function testCanParseCSVWithHeaders($value = '') $array = Parse::fromCSV('foo;bar;bis'.PHP_EOL."bar\tfoo\tter", true); $results = [['foo' => 'bar', 'bar' => 'foo', 'bis' => 'ter']]; - $this->assertEquals($results, $array); + $this->assertSame($results, $array); } //////////////////////////////////////////////////////////////////// @@ -117,11 +120,15 @@ public function testCanParseCSVWithHeaders($value = '') /** * @dataProvider provideSwitchers + * + * @param mixed $method + * @param mixed $from + * @param mixed $to */ public function testCanSwitchTypes($method, $from, $to) { $from = Parse::$method($from); - $this->assertEquals($to, $from); + $this->assertSame($to, $from); } } diff --git a/tests/Types/ArraysTest.php b/tests/Types/ArraysTest.php index 0a69cbf..e29ddad 100644 --- a/tests/Types/ArraysTest.php +++ b/tests/Types/ArraysTest.php @@ -14,6 +14,9 @@ use Underscore\Underscore; use Underscore\UnderscoreTestCase; +/** + * @coversNothing + */ class ArraysTest extends UnderscoreTestCase { // Tests --------------------------------------------------------- / @@ -22,14 +25,14 @@ public function testCanCreateArray() { $array = Arrays::create(); - $this->assertEquals([], $array->obtain()); + $this->assertSame([], $array->obtain()); } public function testCanUseClassDirectly() { $under = Arrays::get($this->array, 'foo'); - $this->assertEquals('bar', $under); + $this->assertSame('bar', $under); } public function testCanCreateChainableObject() @@ -37,21 +40,21 @@ public function testCanCreateChainableObject() $under = Underscore::from($this->arrayNumbers); $under = $under->get(1); - $this->assertEquals(2, $under); + $this->assertSame(2, $under); } public function testCanGetKeys() { $array = Arrays::keys($this->array); - $this->assertEquals(['foo', 'bis'], $array); + $this->assertSame(['foo', 'bis'], $array); } public function testCanGetValues() { $array = Arrays::values($this->array); - $this->assertEquals(['bar', 'ter'], $array); + $this->assertSame(['bar', 'ter'], $array); } public function testCanSetValues() @@ -59,7 +62,7 @@ public function testCanSetValues() $array = ['foo' => ['foo' => 'bar'], 'bar' => 'bis']; $array = Arrays::set($array, 'foo.bar.bis', 'ter'); - $this->assertEquals('ter', $array['foo']['bar']['bis']); + $this->assertSame('ter', $array['foo']['bar']['bis']); $this->assertArrayHasKey('bar', $array); } @@ -69,17 +72,16 @@ public function testCanRemoveValues() $matcher = $this->arrayMulti; unset($matcher[0]['foo']); - $this->assertEquals($matcher, $array); + $this->assertSame($matcher, $array); } public function testCanRemoveMultipleValues() { $array = Arrays::remove($this->arrayMulti, ['0.foo', '1.foo']); $matcher = $this->arrayMulti; - unset($matcher[0]['foo']); - unset($matcher[1]['foo']); + unset($matcher[0]['foo'], $matcher[1]['foo']); - $this->assertEquals($matcher, $array); + $this->assertSame($matcher, $array); } public function testCanReturnAnArrayWithoutSomeValues() @@ -87,7 +89,7 @@ public function testCanReturnAnArrayWithoutSomeValues() $array = ['foo', 'foo', 'bar', 'bis', 'bar', 'bis', 'ter']; $array = Arrays::without($array, 'foo', 'bar'); - $this->assertEquals([3 => 'bis', 5 => 'bis', 6 => 'ter'], $array); + $this->assertSame([3 => 'bis', 5 => 'bis', 6 => 'ter'], $array); $this->assertNotContains('foo', Arrays::without($array, 'foo', 'bar')); $this->assertNotContains('bar', Arrays::without($array, 'foo', 'bar')); // new use case @@ -100,14 +102,14 @@ public function testCanGetSumOfArray() { $array = Arrays::sum([1, 2, 3]); - $this->assertEquals(6, $array); + $this->assertSame(6, $array); } public function testCanGetcountArray() { $array = Arrays::size([1, 2, 3]); - $this->assertEquals(3, $array); + $this->assertSame(3, $array); } public function testCanSeeIfArrayContainsValue() @@ -131,7 +133,7 @@ public function testCanGetValueFromArray() $array = ['foo' => ['bar' => 'bis']]; $under = Arrays::get($array, 'foo.bar'); - $this->assertEquals('bis', $under); + $this->assertSame('bis', $under); } public function testCantConflictWithNativeFunctions() @@ -139,7 +141,7 @@ public function testCantConflictWithNativeFunctions() $array = ['foo' => ['bar' => 'bis']]; $under = Arrays::get($array, 'ter', 'str_replace'); - $this->assertEquals('str_replace', $under); + $this->assertSame('str_replace', $under); } public function testCanFallbackClosure() @@ -149,7 +151,7 @@ public function testCanFallbackClosure() return 'closure'; }); - $this->assertEquals('closure', $under); + $this->assertSame('closure', $under); } public function testCanDoSomethingAtEachValue() @@ -173,18 +175,18 @@ public function testCanActOnEachValueFromArray() $under = Arrays::each($this->array, $closure); $result = ['foo' => 'foo:bar', 'bis' => 'bis:ter']; - $this->assertEquals($result, $under); + $this->assertSame($result, $under); } public function testCanFindAValueInAnArray() { $under = Arrays::find($this->arrayNumbers, function ($value) { - return $value % 2 === 0; + return 0 === $value % 2; }); - $this->assertEquals(2, $under); + $this->assertSame(2, $under); $unfound = Arrays::find($this->arrayNumbers, function ($value) { - return $value === 5; + return 5 === $value; }); $this->assertNull($unfound); } @@ -192,19 +194,19 @@ public function testCanFindAValueInAnArray() public function testCanFilterValuesFromAnArray() { $under = Arrays::filter($this->arrayNumbers, function ($value) { - return $value % 2 !== 0; + return 0 !== $value % 2; }); - $this->assertEquals([0 => 1, 2 => 3], $under); + $this->assertSame([0 => 1, 2 => 3], $under); } public function testCanFilterRejectedValuesFromAnArray() { $under = Arrays::reject($this->arrayNumbers, function ($value) { - return $value % 2 !== 0; + return 0 !== $value % 2; }); - $this->assertEquals([1 => 2], $under); + $this->assertSame([1 => 2], $under); } public function testCanMatchAnArrayContent() @@ -219,7 +221,7 @@ public function testCanMatchAnArrayContent() public function testCanMatchPathOfAnArrayContent() { $under = Arrays::matchesAny($this->arrayNumbers, function ($value) { - return $value === 2; + return 2 === $value; }); $this->assertTrue($under); @@ -230,7 +232,7 @@ public function testCanInvokeFunctionsOnValues() $array = [' foo ', ' bar ']; $array = Arrays::invoke($array, 'trim'); - $this->assertEquals(['foo', 'bar'], $array); + $this->assertSame(['foo', 'bar'], $array); } public function testCanInvokeFunctionsOnValuesWithSingleArgument() @@ -238,7 +240,7 @@ public function testCanInvokeFunctionsOnValuesWithSingleArgument() $array = ['_____foo', '____bar ']; $array = Arrays::invoke($array, 'trim', ' _'); - $this->assertEquals(['foo', 'bar'], $array); + $this->assertSame(['foo', 'bar'], $array); } public function testCanInvokeFunctionsWithDifferentArguments() @@ -246,7 +248,7 @@ public function testCanInvokeFunctionsWithDifferentArguments() $array = ['_____foo ', '__bar ']; $array = Arrays::invoke($array, 'trim', ['_', ' ']); - $this->assertEquals(['foo ', '__bar'], $array); + $this->assertSame(['foo ', '__bar'], $array); } public function testCanPluckColumns() @@ -254,7 +256,7 @@ public function testCanPluckColumns() $under = Arrays::pluck($this->arrayMulti, 'foo'); $matcher = ['bar', 'bar', null]; - $this->assertEquals($matcher, $under); + $this->assertSame($matcher, $under); } public function testCanCalculateAverageValue() @@ -267,9 +269,9 @@ public function testCanCalculateAverageValue() $average2 = Arrays::average($average2); $average3 = Arrays::average($average3); - $this->assertEquals(13, $average1); - $this->assertEquals(0, $average2); - $this->assertEquals(10, $average3); + $this->assertSame(13, $average1); + $this->assertSame(0, $average2); + $this->assertSame(10, $average3); } public function testCanGetFirstValue() @@ -277,36 +279,36 @@ public function testCanGetFirstValue() $under1 = Arrays::first($this->array); $under2 = Arrays::first($this->arrayNumbers, 2); - $this->assertEquals('bar', $under1); - $this->assertEquals([1, 2], $under2); + $this->assertSame('bar', $under1); + $this->assertSame([1, 2], $under2); } public function testCanGetLastValue() { $under = Arrays::last($this->array); - $this->assertEquals('ter', $under); + $this->assertSame('ter', $under); } public function testCanGetLastElements() { $under = Arrays::last($this->arrayNumbers, 2); - $this->assertEquals([2, 3], $under); + $this->assertSame([2, 3], $under); } public function testCanXInitialElements() { $under = Arrays::initial($this->arrayNumbers, 1); - $this->assertEquals([1, 2], $under); + $this->assertSame([1, 2], $under); } public function testCanGetRestFromArray() { $under = Arrays::rest($this->arrayNumbers, 1); - $this->assertEquals([2, 3], $under); + $this->assertSame([2, 3], $under); } public function testCanCleanArray() @@ -314,14 +316,14 @@ public function testCanCleanArray() $array = [false, true, 0, 1, 'full', '']; $array = Arrays::clean($array); - $this->assertEquals([1 => true, 3 => 1, 4 => 'full'], $array); + $this->assertSame([1 => true, 3 => 1, 4 => 'full'], $array); } public function testCanGetMaxValueFromAnArray() { $under = Arrays::max($this->arrayNumbers); - $this->assertEquals(3, $under); + $this->assertSame(3, $under); } public function testCanGetMaxValueFromAnArrayWithClosure() @@ -330,14 +332,14 @@ public function testCanGetMaxValueFromAnArrayWithClosure() return $value * -1; }); - $this->assertEquals(-1, $under); + $this->assertSame(-1, $under); } public function testCanGetMinValueFromAnArray() { $under = Arrays::min($this->arrayNumbers); - $this->assertEquals(1, $under); + $this->assertSame(1, $under); } public function testCanGetMinValueFromAnArrayWithClosure() @@ -346,71 +348,71 @@ public function testCanGetMinValueFromAnArrayWithClosure() return $value * -1; }); - $this->assertEquals(-3, $under); + $this->assertSame(-3, $under); } public function testCanSortKeys() { $under = Arrays::sortKeys(['z' => 0, 'b' => 1, 'r' => 2]); - $this->assertEquals(['b' => 1, 'r' => 2, 'z' => 0], $under); + $this->assertSame(['b' => 1, 'r' => 2, 'z' => 0], $under); $under = Arrays::sortKeys(['z' => 0, 'b' => 1, 'r' => 2], 'desc'); - $this->assertEquals(['z' => 0, 'r' => 2, 'b' => 1], $under); + $this->assertSame(['z' => 0, 'r' => 2, 'b' => 1], $under); } public function testCanSortValues() { $under = Arrays::sort([5, 3, 1, 2, 4], null, 'desc'); - $this->assertEquals([5, 4, 3, 2, 1], $under); + $this->assertSame([5, 4, 3, 2, 1], $under); $under = Arrays::sort(range(1, 5), function ($value) { - return $value % 2 === 0; + return 0 === $value % 2; }); - $this->assertEquals([1, 3, 5, 2, 4], $under); + $this->assertSame([1, 3, 5, 2, 4], $under); } public function testCanGroupValues() { $under = Arrays::group(range(1, 5), function ($value) { - return $value % 2 === 0; + return 0 === $value % 2; }); $matcher = [ [1, 3, 5], [2, 4], ]; - $this->assertEquals($matcher, $under); + $this->assertSame($matcher, $under); } public function testCanGroupValuesWithSavingKeys() { $grouper = function ($value) { - return $value % 2 === 0; + return 0 === $value % 2; }; $under = Arrays::group(range(1, 5), $grouper, true); $matcher = [ [0 => 1, 2 => 3, 4 => 5], [1 => 2, 3 => 4], ]; - $this->assertEquals($matcher, $under); + $this->assertSame($matcher, $under); } public function testCanGroupValuesWithNonExistingKey() { - $this->assertEquals([], Arrays::group(range(1, 5), 'unknown', true)); - $this->assertEquals([], Arrays::group(range(1, 5), 'unknown', false)); + $this->assertSame([], Arrays::group(range(1, 5), 'unknown', true)); + $this->assertSame([], Arrays::group(range(1, 5), 'unknown', false)); } public function testCanCreateFromRange() { $range = Arrays::range(5); - $this->assertEquals([1, 2, 3, 4, 5], $range); + $this->assertSame([1, 2, 3, 4, 5], $range); $range = Arrays::range(-2, 2); - $this->assertEquals([-2, -1, 0, 1, 2], $range); + $this->assertSame([-2, -1, 0, 1, 2], $range); $range = Arrays::range(1, 10, 2); - $this->assertEquals([1, 3, 5, 7, 9], $range); + $this->assertSame([1, 3, 5, 7, 9], $range); } public function testCantChainRange() @@ -424,14 +426,14 @@ public function testCanCreateFromRepeat() { $repeat = Arrays::repeat('foo', 3); - $this->assertEquals(['foo', 'foo', 'foo'], $repeat); + $this->assertSame(['foo', 'foo', 'foo'], $repeat); } public function testCanMergeArrays() { $array = Arrays::merge($this->array, ['foo' => 3], ['kal' => 'mon']); - $this->assertEquals(['foo' => 3, 'bis' => 'ter', 'kal' => 'mon'], $array); + $this->assertSame(['foo' => 3, 'bis' => 'ter', 'kal' => 'mon'], $array); } public function testCanGetRandomValue() @@ -453,7 +455,7 @@ public function testCanSearchForAValue() { $array = Arrays::search($this->array, 'ter'); - $this->assertEquals('bis', $array); + $this->assertSame('bis', $array); } public function testCanDiffBetweenArrays() @@ -461,29 +463,29 @@ public function testCanDiffBetweenArrays() $array = Arrays::diff($this->array, ['foo' => 'bar', 'ter' => 'kal']); $chain = Arrays::from($this->array)->diff(['foo' => 'bar', 'ter' => 'kal']); - $this->assertEquals(['bis' => 'ter'], $array); - $this->assertEquals(['bis' => 'ter'], $chain->obtain()); + $this->assertSame(['bis' => 'ter'], $array); + $this->assertSame(['bis' => 'ter'], $chain->obtain()); } public function testCanRemoveFirstValueFromAnArray() { $array = Arrays::removeFirst($this->array); - $this->assertEquals(['bis' => 'ter'], $array); + $this->assertSame(['bis' => 'ter'], $array); } public function testCanRemoveLasttValueFromAnArray() { $array = Arrays::removeLast($this->array); - $this->assertEquals(['foo' => 'bar'], $array); + $this->assertSame(['foo' => 'bar'], $array); } public function testCanImplodeAnArray() { $array = Arrays::implode($this->array, ','); - $this->assertEquals('bar,ter', $array); + $this->assertSame('bar,ter', $array); } public function testCanFlattenArraysToDotNotation() @@ -505,7 +507,7 @@ public function testCanFlattenArraysToDotNotation() $flatten = Arrays::flatten($array); - $this->assertEquals($flatten, $flattened); + $this->assertSame($flatten, $flattened); } public function testCanFlattenArraysToCustomNotation() @@ -527,7 +529,7 @@ public function testCanFlattenArraysToCustomNotation() $flatten = Arrays::flatten($array, '/'); - $this->assertEquals($flatten, $flattened); + $this->assertSame($flatten, $flattened); } public function testCanReplaceValues() @@ -535,7 +537,7 @@ public function testCanReplaceValues() $array = Arrays::replace($this->array, 'foo', 'notfoo', 'notbar'); $matcher = ['notfoo' => 'notbar', 'bis' => 'ter']; - $this->assertEquals($matcher, $array); + $this->assertSame($matcher, $array); } public function testCanPrependValuesToArrays() @@ -543,7 +545,7 @@ public function testCanPrependValuesToArrays() $array = Arrays::prepend($this->array, 'foo'); $matcher = [0 => 'foo', 'foo' => 'bar', 'bis' => 'ter']; - $this->assertEquals($matcher, $array); + $this->assertSame($matcher, $array); } public function testCanAppendValuesToArrays() @@ -551,7 +553,7 @@ public function testCanAppendValuesToArrays() $array = Arrays::append($this->array, 'foo'); $matcher = ['foo' => 'bar', 'bis' => 'ter', 0 => 'foo']; - $this->assertEquals($matcher, $array); + $this->assertSame($matcher, $array); } public function testCanReplaceValuesInArrays() @@ -559,7 +561,7 @@ public function testCanReplaceValuesInArrays() $array = $this->array; $array = Arrays::replaceValue($array, 'bar', 'replaced'); - $this->assertEquals('replaced', $array['foo']); + $this->assertSame('replaced', $array['foo']); } public function testCanReplaceKeysInArray() @@ -567,7 +569,7 @@ public function testCanReplaceKeysInArray() $array = $this->array; $array = Arrays::replaceKeys($array, ['bar', 'ter']); - $this->assertEquals(['bar' => 'bar', 'ter' => 'ter'], $array); + $this->assertSame(['bar' => 'bar', 'ter' => 'ter'], $array); } public function testCanGetIntersectionOfTwoArrays() @@ -576,7 +578,7 @@ public function testCanGetIntersectionOfTwoArrays() $b = ['bar', 'baz']; $array = Arrays::intersection($a, $b); - $this->assertEquals(['bar'], $array); + $this->assertSame(['bar'], $array); } public function testIntersectsBooleanFlag() @@ -605,22 +607,22 @@ public function testFilterBy() $b = Arrays::filterBy($a, 'name', 'baz'); $this->assertCount(1, $b); - $this->assertEquals(2365, $b[0]['value']); + $this->assertSame(2365, $b[0]['value']); $b = Arrays::filterBy($a, 'name', ['baz']); $this->assertCount(1, $b); - $this->assertEquals(2365, $b[0]['value']); + $this->assertSame(2365, $b[0]['value']); $c = Arrays::filterBy($a, 'value', 2468); $this->assertCount(1, $c); - $this->assertEquals('primary', $c[0]['group']); + $this->assertSame('primary', $c[0]['group']); $d = Arrays::filterBy($a, 'group', 'primary'); $this->assertCount(3, $d); $e = Arrays::filterBy($a, 'value', 2000, 'lt'); $this->assertCount(1, $e); - $this->assertEquals(1468, $e[0]['value']); + $this->assertSame(1468, $e[0]['value']); $e = Arrays::filterBy($a, 'value', [2468, 2365], 'contains'); $this->assertCount(2, $e); @@ -649,27 +651,27 @@ public function testFindBy() ]; $b = Arrays::findBy($a, 'name', 'baz'); - $this->assertTrue(is_array($b)); + $this->assertInternalType('array', $b); $this->assertCount(4, $b); // this is counting the number of keys in the array (id,name,group,value) - $this->assertEquals(2365, $b['value']); + $this->assertSame(2365, $b['value']); $this->assertArrayHasKey('name', $b); $this->assertArrayHasKey('group', $b); $this->assertArrayHasKey('value', $b); $c = Arrays::findBy($a, 'value', 2468); - $this->assertTrue(is_array($c)); + $this->assertInternalType('array', $c); $this->assertCount(4, $c); - $this->assertEquals('primary', $c['group']); + $this->assertSame('primary', $c['group']); $d = Arrays::findBy($a, 'group', 'primary'); - $this->assertTrue(is_array($d)); + $this->assertInternalType('array', $d); $this->assertCount(4, $d); - $this->assertEquals('foo', $d['name']); + $this->assertSame('foo', $d['name']); $e = Arrays::findBy($a, 'value', 2000, 'lt'); - $this->assertTrue(is_array($e)); + $this->assertInternalType('array', $e); $this->assertCount(4, $e); - $this->assertEquals(1468, $e['value']); + $this->assertSame(1468, $e['value']); } public function testRemoveValue() @@ -697,7 +699,7 @@ public function testCanGetUniqueArray() $a = [1, 1, 2]; $result = Arrays::unique($a); - $this->assertEquals([1, 2], $result); + $this->assertSame([1, 2], $result); } public function testCanIndexBy() @@ -714,7 +716,7 @@ public function testCanIndexBy() 60 => ['name' => 'curly', 'age' => 60], ]; - $this->assertEquals($expected, Arrays::indexBy($array, 'age')); + $this->assertSame($expected, Arrays::indexBy($array, 'age')); } public function testIndexByReturnSome() @@ -730,7 +732,7 @@ public function testIndexByReturnSome() 50 => ['name' => 'larry', 'age' => 50], ]; - $this->assertEquals($expected, Arrays::indexBy($array, 'age')); + $this->assertSame($expected, Arrays::indexBy($array, 'age')); } public function testIndexByReturnEmpty() @@ -741,6 +743,6 @@ public function testIndexByReturnEmpty() ['name' => 'curly'], ]; - $this->assertEquals([], Arrays::indexBy($array, 'vaaaa')); + $this->assertSame([], Arrays::indexBy($array, 'vaaaa')); } } diff --git a/tests/Types/FunctionsTest.php b/tests/Types/FunctionsTest.php index 2661c1c..f7dd594 100644 --- a/tests/Types/FunctionsTest.php +++ b/tests/Types/FunctionsTest.php @@ -13,6 +13,9 @@ use Underscore\UnderscoreTestCase; +/** + * @coversNothing + */ class FunctionsTest extends UnderscoreTestCase { public function testCanCallFunctionOnlyOnce() @@ -25,7 +28,7 @@ public function testCanCallFunctionOnlyOnce() $function(); $function(); - $this->assertEquals(1, $number); + $this->assertSame(1, $number); } public function testCanCallFunctionOnlyXTimes() @@ -41,7 +44,7 @@ public function testCanCallFunctionOnlyXTimes() $function(); $function(); - $this->assertEquals(3, $number); + $this->assertSame(3, $number); } public function testCanCallFunctionAfterXTimes() @@ -57,7 +60,7 @@ public function testCanCallFunctionAfterXTimes() $function(); $function(); - $this->assertEquals(2, $number); + $this->assertSame(2, $number); } public function testCanCacheFunctionResults() @@ -68,8 +71,8 @@ public function testCanCacheFunctionResults() $result = $function('foobar'); - $this->assertEquals($result, $function('foobar')); - $this->assertNotEquals($result, $function('barfoo')); + $this->assertSame($result, $function('foobar')); + $this->assertNotSame($result, $function('barfoo')); } public function testCanThrottleFunctions() @@ -84,7 +87,7 @@ public function testCanThrottleFunctions() sleep(1); $function(); - $this->assertEquals(2, $number); + $this->assertSame(2, $number); } public function testCanPartiallyApplyArguments() @@ -93,7 +96,7 @@ public function testCanPartiallyApplyArguments() return implode('', func_get_args()); }, 2, null, 6); - $this->assertEquals('246', $function(4)); - $this->assertEquals('2468', $function(4, 8)); + $this->assertSame('246', $function(4)); + $this->assertSame('2468', $function(4, 8)); } } diff --git a/tests/Types/NumberTest.php b/tests/Types/NumberTest.php index c8b7d58..308067f 100644 --- a/tests/Types/NumberTest.php +++ b/tests/Types/NumberTest.php @@ -13,50 +13,53 @@ use Underscore\UnderscoreTestCase; +/** + * @coversNothing + */ class NumberTest extends UnderscoreTestCase { public function testCanCreateNewNumber() { - $this->assertEquals(0, Number::create()->obtain()); + $this->assertSame(0, Number::create()->obtain()); } public function testCanAccessStrPad() { $number = Number::pad(5, 3, 1, STR_PAD_BOTH); - $this->assertEquals('151', $number); + $this->assertSame('151', $number); } public function testCanPadANumber() { $number = Number::padding(5, 3); - $this->assertEquals('050', $number); + $this->assertSame('050', $number); } public function testCanPadANumberOnTheLeft() { $number = Number::paddingLeft(5, 3); - $this->assertEquals('005', $number); + $this->assertSame('005', $number); } public function testCanPadANumberOnTheRight() { $number = Number::paddingRight(5, 3); - $this->assertEquals('500', $number); + $this->assertSame('500', $number); } public function testCanUsePhpRoundingMethods() { $number = Number::round(5.33); - $this->assertEquals(5, $number); + $this->assertSame(5, $number); $number = Number::ceil(5.33); - $this->assertEquals(6, $number); + $this->assertSame(6, $number); $number = Number::floor(5.33); - $this->assertEquals(5, $number); + $this->assertSame(5, $number); } } diff --git a/tests/Types/ObjectTest.php b/tests/Types/ObjectTest.php index e5ae080..36aa37d 100644 --- a/tests/Types/ObjectTest.php +++ b/tests/Types/ObjectTest.php @@ -14,6 +14,9 @@ use Underscore\Dummies\DummyDefault; use Underscore\UnderscoreTestCase; +/** + * @coversNothing + */ class ObjectTest extends UnderscoreTestCase { public function testCanCreateObject() @@ -26,26 +29,26 @@ public function testCanCreateObject() public function testCanObjectifyAnArray() { $object = Object::from(['foo' => 'bar']); - $this->assertEquals('bar', $object->foo); + $this->assertSame('bar', $object->foo); $object->bis = 'ter'; - $this->assertEquals('ter', $object->bis); + $this->assertSame('ter', $object->bis); - $this->assertEquals(['foo' => 'bar', 'bis' => 'ter'], (array) $object->obtain()); + $this->assertSame(['foo' => 'bar', 'bis' => 'ter'], (array) $object->obtain()); } public function testCanGetKeys() { $object = Object::keys($this->object); - $this->assertEquals(['foo', 'bis'], $object); + $this->assertSame(['foo', 'bis'], $object); } public function testCanGetValues() { $object = Object::Values($this->object); - $this->assertEquals(['bar', 'ter'], $object); + $this->assertSame(['bar', 'ter'], $object); } public function testCanGetMethods() @@ -67,7 +70,7 @@ public function testCanGetMethods() '__call', ]; - $this->assertEquals($methods, Object::methods(new DummyDefault())); + $this->assertSame($methods, Object::methods(new DummyDefault())); } public function testCanPluckColumns() @@ -75,7 +78,7 @@ public function testCanPluckColumns() $object = Object::pluck($this->objectMulti, 'foo'); $matcher = (object) ['bar', 'bar', null]; - $this->assertEquals($matcher, $object); + $this->assertSame($matcher, $object); } public function testCanSetValues() @@ -83,7 +86,7 @@ public function testCanSetValues() $object = (object) ['foo' => ['foo' => 'bar'], 'bar' => 'bis']; $object = Object::set($object, 'foo.bar.bis', 'ter'); - $this->assertEquals('ter', $object->foo['bar']['bis']); + $this->assertSame('ter', $object->foo['bar']['bis']); $this->assertObjectHasAttribute('bar', $object); } @@ -93,14 +96,14 @@ public function testCanRemoveValues() $matcher = (array) $this->objectMulti; unset($matcher[0]->foo); - $this->assertEquals((object) $matcher, $array); + $this->assertSame((object) $matcher, $array); } public function testCanConvertToJson() { $under = Object::toJSON($this->object); - $this->assertEquals('{"foo":"bar","bis":"ter"}', $under); + $this->assertSame('{"foo":"bar","bis":"ter"}', $under); } public function testCanSort() @@ -112,22 +115,22 @@ public function testCanSort() $collection = [$object, $object_alt]; $under = Object::sort($collection, 'name', 'asc'); - $this->assertEquals([$object_alt, $object], $under); + $this->assertSame([$object_alt, $object], $under); $under = Object::sort($collection, 'child.sort', 'desc'); - $this->assertEquals([$object_alt, $object], $under); + $this->assertSame([$object_alt, $object], $under); $under = Object::sort($collection, function ($value) { return $value->child->sort; }, 'desc'); - $this->assertEquals([$object_alt, $object], $under); + $this->assertSame([$object_alt, $object], $under); } public function testCanConvertToArray() { $object = Object::toArray($this->object); - $this->assertEquals($this->array, $object); + $this->assertSame($this->array, $object); } public function testCanUnpackObjects() @@ -138,9 +141,9 @@ public function testCanUnpackObjects() $this->assertObjectHasAttribute('name', $objectAuto); $this->assertObjectHasAttribute('age', $objectAuto); - $this->assertEquals('foo', $objectAuto->name); - $this->assertEquals(18, $objectAuto->age); - $this->assertEquals($objectManual, $objectAuto); + $this->assertSame('foo', $objectAuto->name); + $this->assertSame(18, $objectAuto->age); + $this->assertSame($objectManual, $objectAuto); } public function testCanReplaceValues() @@ -148,7 +151,7 @@ public function testCanReplaceValues() $object = Object::replace($this->object, 'foo', 'notfoo', 'notbar'); $matcher = (object) ['notfoo' => 'notbar', 'bis' => 'ter']; - $this->assertEquals($matcher, $object); + $this->assertSame($matcher, $object); } public function testCanSetAnGetValues() @@ -157,8 +160,8 @@ public function testCanSetAnGetValues() $getset = Object::setAndGet($object, 'set', 'get'); $get = Object::get($object, 'set'); - $this->assertEquals($getset, 'get'); - $this->assertEquals($get, $getset); + $this->assertSame($getset, 'get'); + $this->assertSame($get, $getset); } public function testFilterBy() @@ -172,18 +175,18 @@ public function testFilterBy() $b = Object::filterBy($a, 'name', 'baz'); $this->assertCount(1, $b); - $this->assertEquals(2365, $b[0]->value); + $this->assertSame(2365, $b[0]->value); $c = Object::filterBy($a, 'value', 2468); $this->assertCount(1, $c); - $this->assertEquals('primary', $c[0]->group); + $this->assertSame('primary', $c[0]->group); $d = Object::filterBy($a, 'group', 'primary'); $this->assertCount(3, $d); $e = Object::filterBy($a, 'value', 2000, 'lt'); $this->assertCount(1, $e); - $this->assertEquals(1468, $e[0]->value); + $this->assertSame(1468, $e[0]->value); } public function testFindBy() @@ -197,21 +200,21 @@ public function testFindBy() $b = Object::findBy($a, 'name', 'baz'); $this->assertInstanceOf('\stdClass', $b); - $this->assertEquals(2365, $b->value); + $this->assertSame(2365, $b->value); $this->assertObjectHasAttribute('name', $b); $this->assertObjectHasAttribute('group', $b); $this->assertObjectHasAttribute('value', $b); $c = Object::findBy($a, 'value', 2468); $this->assertInstanceOf('\stdClass', $c); - $this->assertEquals('primary', $c->group); + $this->assertSame('primary', $c->group); $d = Object::findBy($a, 'group', 'primary'); $this->assertInstanceOf('\stdClass', $d); - $this->assertEquals('foo', $d->name); + $this->assertSame('foo', $d->name); $e = Object::findBy($a, 'value', 2000, 'lt'); $this->assertInstanceOf('\stdClass', $e); - $this->assertEquals(1468, $e->value); + $this->assertSame(1468, $e->value); } } diff --git a/tests/Types/StringTest.php b/tests/Types/StringTest.php index d4d36ec..db71d27 100644 --- a/tests/Types/StringTest.php +++ b/tests/Types/StringTest.php @@ -14,6 +14,9 @@ use Underscore\Underscore; use Underscore\UnderscoreTestCase; +/** + * @coversNothing + */ class StringTest extends UnderscoreTestCase { public $remove = 'foo foo bar foo kal ter son'; @@ -30,7 +33,6 @@ public function provideAccord() public function provideFind() { return [ - // Simple cases [false, 'foo', 'bar'], [true, 'foo', 'foo'], @@ -56,15 +58,15 @@ public function testCanCreateString() { $string = Strings::create(); - $this->assertEquals('', $string->obtain()); + $this->assertSame('', $string->obtain()); } public function testDoesntPluralizeTwice() { $string = new Strings('person'); - $this->assertEquals('people', $string->plural()); - $this->assertEquals('people', $string->plural()); + $this->assertSame('people', $string->plural()); + $this->assertSame('people', $string->plural()); } public function testHasAccessToStrMethods() @@ -72,51 +74,57 @@ public function testHasAccessToStrMethods() $string1 = Strings::limit('foo', 1); $string2 = Underscore::from('foo')->limit(1)->obtain(); - $this->assertEquals('f...', $string1); - $this->assertEquals('f...', $string2); + $this->assertSame('f...', $string1); + $this->assertSame('f...', $string2); } public function testCanRemoveTextFromString() { $return = Strings::remove($this->remove, 'bar'); - $this->assertEquals('foo foo foo kal ter son', $return); + $this->assertSame('foo foo foo kal ter son', $return); } public function testCanRemoveMultipleTextsFromString() { $return = Strings::remove($this->remove, ['foo', 'son']); - $this->assertEquals('bar kal ter', $return); + $this->assertSame('bar kal ter', $return); } public function testCanToggleBetweenTwoStrings() { $toggle = Strings::toggle('foo', 'foo', 'bar'); - $this->assertEquals('bar', $toggle); + $this->assertSame('bar', $toggle); } public function testCannotLooselyToggleBetweenStrings() { $toggle = Strings::toggle('dei', 'foo', 'bar'); - $this->assertEquals('dei', $toggle); + $this->assertSame('dei', $toggle); } public function testCanLooselyToggleBetweenStrings() { $toggle = Strings::toggle('dei', 'foo', 'bar', true); - $this->assertEquals('foo', $toggle); + $this->assertSame('foo', $toggle); } public function testCanRepeatString() { $string = Strings::from('foo')->repeat(3)->obtain(); - $this->assertEquals('foofoofoo', $string); + $this->assertSame('foofoofoo', $string); } /** * @dataProvider provideFind + * + * @param mixed $expect + * @param mixed $needle + * @param mixed $haystack + * @param mixed $caseSensitive + * @param mixed $absoluteFinding */ public function testCanFindStringsInStrings( $expect, @@ -127,7 +135,7 @@ public function testCanFindStringsInStrings( ) { $result = Strings::find($haystack, $needle, $caseSensitive, $absoluteFinding); - $this->assertEquals($expect, $result); + $this->assertSame($expect, $result); } public function testCanAssertAStringStartsWith() @@ -144,60 +152,63 @@ public function testCanAssertAStringEndsWith() public function testStringsCanBeSlugged() { - $this->assertEquals('my-new-post', Strings::slugify('My_nEw\\\/ @ post!!!')); - $this->assertEquals('my_new_post', Strings::slugify('My nEw post!!!', '_')); + $this->assertSame('my-new-post', Strings::slugify('My_nEw\\\/ @ post!!!')); + $this->assertSame('my_new_post', Strings::slugify('My nEw post!!!', '_')); } public function testRandomStringsCanBeGenerated() { - $this->assertEquals(40, strlen(Strings::random(40))); + $this->assertSame(40, strlen(Strings::random(40))); } /** * @dataProvider provideAccord + * + * @param mixed $number + * @param mixed $expect */ public function testCanAccordAStringToItsNumeral($number, $expect) { $result = Strings::accord($number, '%d things', 'one thing', 'nothing'); - $this->assertEquals($expect, $result); + $this->assertSame($expect, $result); } public function testCanSliceFromAString() { $string = Strings::sliceFrom('abcdef', 'c'); - return $this->assertEquals('cdef', $string); + return $this->assertSame('cdef', $string); } public function testCanSliceToAString() { $string = Strings::sliceTo('abcdef', 'c'); - return $this->assertEquals('ab', $string); + return $this->assertSame('ab', $string); } public function testCanSliceAString() { $string = Strings::slice('abcdef', 'c'); - return $this->assertEquals(['ab', 'cdef'], $string); + return $this->assertSame(['ab', 'cdef'], $string); } public function testCanUseCorrectOrderForStrReplace() { $string = Strings::replace('foo', 'foo', 'bar'); - $this->assertEquals('bar', $string); + $this->assertSame('bar', $string); } public function testCanExplodeString() { $string = Strings::explode('foo bar foo', ' '); - $this->assertEquals(['foo', 'bar', 'foo'], $string); + $this->assertSame(['foo', 'bar', 'foo'], $string); $string = Strings::explode('foo bar foo', ' ', -1); - $this->assertEquals(['foo', 'bar'], $string); + $this->assertSame(['foo', 'bar'], $string); } public function testCanGenerateRandomWords() @@ -205,60 +216,60 @@ public function testCanGenerateRandomWords() $string = Strings::randomStrings($words = 5, $size = 5); $result = ($words * $size) + ($words * 1) - 1; - $this->assertEquals($result, strlen($string)); + $this->assertSame($result, strlen($string)); } public function testCanConvertToSnakeCase() { $string = Strings::toSnakeCase('thisIsAString'); - $this->assertEquals('this_is_a_string', $string); + $this->assertSame('this_is_a_string', $string); } public function testCanConvertToCamelCase() { $string = Strings::toCamelCase('this_is_a_string'); - $this->assertEquals('thisIsAString', $string); + $this->assertSame('thisIsAString', $string); } public function testCanConvertToPascalCase() { $string = Strings::toPascalCase('this_is_a_string'); - $this->assertEquals('ThisIsAString', $string); + $this->assertSame('ThisIsAString', $string); } public function testCanConvertToLowercase() { - $this->assertEquals('taylor', Strings::lower('TAYLOR')); - $this->assertEquals('άχιστη', Strings::lower('ΆΧΙΣΤΗ')); + $this->assertSame('taylor', Strings::lower('TAYLOR')); + $this->assertSame('άχιστη', Strings::lower('ΆΧΙΣΤΗ')); } public function testCanConvertToUppercase() { - $this->assertEquals('TAYLOR', Strings::upper('taylor')); - $this->assertEquals('ΆΧΙΣΤΗ', Strings::upper('άχιστη')); + $this->assertSame('TAYLOR', Strings::upper('taylor')); + $this->assertSame('ΆΧΙΣΤΗ', Strings::upper('άχιστη')); } public function testCanConvertToTitleCase() { - $this->assertEquals('Taylor', Strings::title('taylor')); - $this->assertEquals('Άχιστη', Strings::title('άχιστη')); + $this->assertSame('Taylor', Strings::title('taylor')); + $this->assertSame('Άχιστη', Strings::title('άχιστη')); } public function testCanLimitStringsByCharacters() { - $this->assertEquals('Tay...', Strings::limit('Taylor', 3)); - $this->assertEquals('Taylor', Strings::limit('Taylor', 6)); - $this->assertEquals('Tay___', Strings::limit('Taylor', 3, '___')); + $this->assertSame('Tay...', Strings::limit('Taylor', 3)); + $this->assertSame('Taylor', Strings::limit('Taylor', 6)); + $this->assertSame('Tay___', Strings::limit('Taylor', 3, '___')); } public function testCanLimitByWords() { - $this->assertEquals('Taylor...', Strings::words('Taylor Otwell', 1)); - $this->assertEquals('Taylor___', Strings::words('Taylor Otwell', 1, '___')); - $this->assertEquals('Taylor Otwell', Strings::words('Taylor Otwell', 3)); + $this->assertSame('Taylor...', Strings::words('Taylor Otwell', 1)); + $this->assertSame('Taylor___', Strings::words('Taylor Otwell', 1, '___')); + $this->assertSame('Taylor Otwell', Strings::words('Taylor Otwell', 3)); } public function testCanCheckIfIsIp() @@ -281,16 +292,16 @@ public function testCanCheckIfIsUrl() public function testCanPrependString() { - $this->assertEquals('foobar', Strings::prepend('bar', 'foo')); + $this->assertSame('foobar', Strings::prepend('bar', 'foo')); } public function testCanAppendString() { - $this->assertEquals('foobar', Strings::append('foo', 'bar')); + $this->assertSame('foobar', Strings::append('foo', 'bar')); } public function testCanGetBaseClass() { - $this->assertEquals('Baz', Strings::baseClass('Foo\Bar\Baz')); + $this->assertSame('Baz', Strings::baseClass('Foo\Bar\Baz')); } } diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index b69506c..3d1a861 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -16,6 +16,9 @@ use Underscore\Types\Arrays; use Underscore\Types\Strings; +/** + * @coversNothing + */ class UnderscoreTest extends UnderscoreTestCase { // Tests --------------------------------------------------------- / @@ -33,14 +36,14 @@ public function testCanRedirectToCorrectClass() { $under = Underscore::contains([1, 2, 3], 3); - $this->assertEquals(2, $under); + $this->assertSame(2, $under); } public function testCanSwitchTypesMidCourse() { $stringToArray = Strings::from('FOO.BAR')->lower()->explode('.')->last()->title(); - $this->assertEquals('Bar', $stringToArray->obtain()); + $this->assertSame('Bar', $stringToArray->obtain()); } public function testCanWrapWithShortcutFunction() @@ -58,10 +61,10 @@ public function testCanWrapWithShortcutFunction() public function testCanHaveAliasesForMethods() { $under = Arrays::select($this->arrayNumbers, function ($value) { - return $value === 1; + return 1 === $value; }); - $this->assertEquals([1], $under); + $this->assertSame([1], $under); } public function testUserCanExtendWithCustomFunctions() @@ -69,12 +72,12 @@ public function testUserCanExtendWithCustomFunctions() Arrays::extend('fooify', function ($array) { return 'bar'; }); - $this->assertEquals('bar', Arrays::fooify(['foo'])); + $this->assertSame('bar', Arrays::fooify(['foo'])); Strings::extend('unfooer', function ($string) { return Strings::replace($string, 'foo', 'bar'); }); - $this->assertEquals('bar', Strings::unfooer('foo')); + $this->assertSame('bar', Strings::unfooer('foo')); } public function testBreakersCantAlterTheOriginalValue() @@ -82,8 +85,8 @@ public function testBreakersCantAlterTheOriginalValue() $object = Arrays::from([1, 2, 3]); $sum = $object->sum(); - $this->assertEquals(6, $sum); - $this->assertEquals([1, 2, 3], $object->obtain()); + $this->assertSame(6, $sum); + $this->assertSame([1, 2, 3], $object->obtain()); } public function testClassesCanExtendCoreTypes() @@ -91,8 +94,8 @@ public function testClassesCanExtendCoreTypes() $class = new DummyClass(); $class->set('foo', 'bar'); - $this->assertEquals('foobar', DummyDefault::create()->obtain()); - $this->assertEquals('{"foo":"bar"}', $class->toJSON()); + $this->assertSame('foobar', DummyDefault::create()->obtain()); + $this->assertSame('{"foo":"bar"}', $class->toJSON()); } public function testClassesCanUpdateSubject() @@ -101,8 +104,8 @@ public function testClassesCanUpdateSubject() $class = $class->getUsers()->toJSON(); $class2 = DummyClass::create()->getUsers()->toJSON(); - $this->assertEquals('[{"foo":"bar"},{"bar":"foo"}]', $class); - $this->assertEquals($class, $class2); + $this->assertSame('[{"foo":"bar"},{"bar":"foo"}]', $class); + $this->assertSame($class, $class2); } public function testClassesCanOverwriteUnderscore() @@ -110,7 +113,7 @@ public function testClassesCanOverwriteUnderscore() $class = new DummyClass(); $class = $class->map(3)->paddingLeft(3)->toJSON(); - $this->assertEquals('"009"', $class); + $this->assertSame('"009"', $class); } public function testMacrosCantConflictBetweenTypes() @@ -122,8 +125,8 @@ public function testMacrosCantConflictBetweenTypes() return 'arrays'; }); - $this->assertEquals('string', Strings::foobar()); - $this->assertEquals('arrays', Arrays::foobar()); + $this->assertSame('string', Strings::foobar()); + $this->assertSame('arrays', Arrays::foobar()); } public function testCanCheckIfSubjectIsEmpty() @@ -137,7 +140,7 @@ public function testCanParseToStringOnToString() { $array = Arrays::from($this->array); - $this->assertEquals('{"foo":"bar","bis":"ter"}', $array->__toString()); + $this->assertSame('{"foo":"bar","bis":"ter"}', $array->__toString()); } public function testUnderscoreFindsRightClassToCall() @@ -147,6 +150,6 @@ public function testUnderscoreFindsRightClassToCall() return $w * $v; }, 1); - $this->assertEquals(60, $product); + $this->assertSame(60, $product); } }