From ef1436be58221509c176c5ea927d944b664e06d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 11:32:35 +0300 Subject: [PATCH 01/27] Move size() test to separate file --- tests/Accessor/BaseAccessorTest.php | 78 +++++++++++++++++++++++++++++ tests/Accessor/SizeAccessorTest.php | 29 +++++++++++ tests/UnderscoreTest.php | 8 --- 3 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 tests/Accessor/BaseAccessorTest.php create mode 100644 tests/Accessor/SizeAccessorTest.php diff --git a/tests/Accessor/BaseAccessorTest.php b/tests/Accessor/BaseAccessorTest.php new file mode 100644 index 0000000..f003c8b --- /dev/null +++ b/tests/Accessor/BaseAccessorTest.php @@ -0,0 +1,78 @@ +name = 'dummy'; + $dummy->foo = 'bar'; + $dummy->baz = 'qux'; + + return $dummy; + } + + /** + * @return object + */ + protected static function getDummy2() + { + $dummy = self::getDummy1(); + $dummy->false = false; + $dummy->null = null; + $dummy->zero = 0; + + return $dummy; + } + + protected static function getDummy3() + { + $dummy = [ + 'Angela' => [ + 'position' => 'dean', + 'sex' => 'female', + ], + 'Bob' => [ + 'position' => 'janitor', + 'sex' => 'male', + ], + 'Mark' => [ + 'position' => 'teacher', + 'sex' => 'male', + 'tenured' => true, + ], + 'Wendy' => [ + 'position' => 'teacher', + 'sex' => 'female', + 'tenured' => 1, + ], + ]; + + return $dummy; + } + + /** + * @return Accessor + */ + abstract protected function getInstance(); + + /** + * @return mixed[] + */ + abstract protected function getTestInvokeData(); + + /** + * @param mixed $data + * @param mixed $expected + * @dataProvider getTestInvokeData + */ + public function testInvoke($data, $expected) + { + $this->assertSame($expected, $this->getInstance()->__invoke(new Collection($data))); + } +} diff --git a/tests/Accessor/SizeAccessorTest.php b/tests/Accessor/SizeAccessorTest.php new file mode 100644 index 0000000..a335154 --- /dev/null +++ b/tests/Accessor/SizeAccessorTest.php @@ -0,0 +1,29 @@ +getDummy1(), 3]; + $ret[] = [$this->getDummy2(), 6]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index ec8a775..481bf49 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -272,14 +272,6 @@ function ($value) { $this->assertSame(false, $value); } - public function testSize() - { - $value = Underscore::from($this->getDummy()) - ->size(); - - $this->assertSame(3, $value); - } - public function testHead() { $value = Underscore::from($this->getDummy()) From e7b6b694e661e831ab69513b0b385419c11126a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 11:41:53 +0300 Subject: [PATCH 02/27] Move all() test to separate file --- tests/Accessor/AllAccessorTest.php | 40 +++++++++++++++++++++++++++++ tests/Accessor/BaseAccessorTest.php | 9 +++---- tests/Accessor/SizeAccessorTest.php | 18 +++++++++---- tests/UnderscoreTest.php | 21 --------------- 4 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 tests/Accessor/AllAccessorTest.php diff --git a/tests/Accessor/AllAccessorTest.php b/tests/Accessor/AllAccessorTest.php new file mode 100644 index 0000000..d46b9cb --- /dev/null +++ b/tests/Accessor/AllAccessorTest.php @@ -0,0 +1,40 @@ +getDummy1()), $func], + ]; + + $ret[] = [ + false, + [new Collection($this->getDummy2()), $func], + ]; + + return $ret; + } +} diff --git a/tests/Accessor/BaseAccessorTest.php b/tests/Accessor/BaseAccessorTest.php index f003c8b..b1996b3 100644 --- a/tests/Accessor/BaseAccessorTest.php +++ b/tests/Accessor/BaseAccessorTest.php @@ -3,7 +3,6 @@ namespace Underscore\Test\Accessor; use Underscore\Accessor; -use Underscore\Collection; abstract class BaseAccessorTest extends \PHPUnit_Framework_TestCase { @@ -57,7 +56,7 @@ protected static function getDummy3() } /** - * @return Accessor + * @return Accessor|callable */ abstract protected function getInstance(); @@ -67,12 +66,12 @@ abstract protected function getInstance(); abstract protected function getTestInvokeData(); /** - * @param mixed $data * @param mixed $expected + * @param mixed $args * @dataProvider getTestInvokeData */ - public function testInvoke($data, $expected) + public function testInvoke($expected, $args) { - $this->assertSame($expected, $this->getInstance()->__invoke(new Collection($data))); + $this->assertSame($expected, call_user_func_array($this->getInstance(), $args)); } } diff --git a/tests/Accessor/SizeAccessorTest.php b/tests/Accessor/SizeAccessorTest.php index a335154..ae2c520 100644 --- a/tests/Accessor/SizeAccessorTest.php +++ b/tests/Accessor/SizeAccessorTest.php @@ -2,7 +2,8 @@ namespace Underscore\Test\Accessor; -use Underscore\Accessor\SizeAccessor; +use Underscore\Accessor; +use Underscore\Collection; class SizeAccessorTest extends BaseAccessorTest { @@ -11,18 +12,25 @@ class SizeAccessorTest extends BaseAccessorTest */ protected function getInstance() { - return new SizeAccessor(); + return new Accessor\SizeAccessor(); } /** - * @return array + * @inheritDoc */ public function getTestInvokeData() { $ret = []; - $ret[] = [$this->getDummy1(), 3]; - $ret[] = [$this->getDummy2(), 6]; + $ret[] = [ + 3, + [new Collection($this->getDummy1())], + ]; + + $ret[] = [ + 6, + [new Collection($this->getDummy2())], + ]; return $ret; } diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 481bf49..9e4e4bd 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -251,27 +251,6 @@ function ($value) { $this->assertSame(false, $value); } - public function testAll() - { - $value = Underscore::from($this->getDummy()) - ->all( - function ($value) { - return 3 <= strlen($value); - } - ); - - $this->assertSame(true, $value); - - $value = Underscore::from($this->getDummy()) - ->all( - function ($value) { - return 3 < strlen($value); - } - ); - - $this->assertSame(false, $value); - } - public function testHead() { $value = Underscore::from($this->getDummy()) From b9fc17053e60b25edcb6c4064d2bf4c99a255e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 11:43:20 +0300 Subject: [PATCH 03/27] Move any() test to separate file --- tests/Accessor/AnyAccessorTest.php | 40 ++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 21 ---------------- 2 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 tests/Accessor/AnyAccessorTest.php diff --git a/tests/Accessor/AnyAccessorTest.php b/tests/Accessor/AnyAccessorTest.php new file mode 100644 index 0000000..c610f8f --- /dev/null +++ b/tests/Accessor/AnyAccessorTest.php @@ -0,0 +1,40 @@ +getDummy1()), $func], + ]; + + $ret[] = [ + true, + [new Collection($this->getDummy2()), $func], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 9e4e4bd..a2ec01c 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -230,27 +230,6 @@ function ($value) { $this->assertSame(['foo' => 'bar', 'baz' => 'qux'], $value); } - public function testAny() - { - $value = Underscore::from($this->getDummy()) - ->any( - function ($value) { - return 3 < strlen($value); - } - ); - - $this->assertSame(true, $value); - - $value = Underscore::from($this->getDummy()) - ->any( - function ($value) { - return strlen($value) < 2; - } - ); - - $this->assertSame(false, $value); - } - public function testHead() { $value = Underscore::from($this->getDummy()) From ba517d54abc12b6db40bdf6e0305c95af45b56ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:20:59 +0300 Subject: [PATCH 04/27] Move contains() test to separate file --- tests/Accessor/ContainsAccessorTest.php | 37 +++++++++++++++++++++++++ tests/UnderscoreTest.php | 6 ---- 2 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 tests/Accessor/ContainsAccessorTest.php diff --git a/tests/Accessor/ContainsAccessorTest.php b/tests/Accessor/ContainsAccessorTest.php new file mode 100644 index 0000000..0d801fc --- /dev/null +++ b/tests/Accessor/ContainsAccessorTest.php @@ -0,0 +1,37 @@ +getDummy1()), 'bar'], + ]; + + $ret[] = [ + false, + [new Collection($this->getDummy1()), 'baz'], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index a2ec01c..2f32ae8 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -187,12 +187,6 @@ public function testPickGetter() $this->assertSame(['foo'], $value); } - public function testContains() - { - $this->assertTrue(Underscore::from($this->getDummy())->contains('bar')); - $this->assertFalse(Underscore::from($this->getDummy())->contains('baz')); - } - public function testFind() { $iterator = function ($needle) { From d234a4feec890a878afcfe9f5595e8536c48497d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:25:50 +0300 Subject: [PATCH 05/27] Move find() test to separate file --- src/Accessor/FindAccessor.php | 2 +- tests/Accessor/FindAccessorTest.php | 43 +++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 11 -------- 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 tests/Accessor/FindAccessorTest.php diff --git a/src/Accessor/FindAccessor.php b/src/Accessor/FindAccessor.php index 268f45c..820fce6 100644 --- a/src/Accessor/FindAccessor.php +++ b/src/Accessor/FindAccessor.php @@ -14,7 +14,7 @@ class FindAccessor extends Accessor * * @param Collection $collection * @param callable $iterator - * @return Collection + * @return bool */ public function __invoke($collection, $iterator) { diff --git a/tests/Accessor/FindAccessorTest.php b/tests/Accessor/FindAccessorTest.php new file mode 100644 index 0000000..8e9463e --- /dev/null +++ b/tests/Accessor/FindAccessorTest.php @@ -0,0 +1,43 @@ +getDummy1()), $func('foo')], + ]; + + $ret[] = [ + true, + [new Collection($this->getDummy2()), $func('bar')], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 2f32ae8..f0af62a 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -187,17 +187,6 @@ public function testPickGetter() $this->assertSame(['foo'], $value); } - public function testFind() - { - $iterator = function ($needle) { - return function ($value) use ($needle) { - return $value === $needle; - }; - }; - $this->assertTrue(Underscore::from($this->getDummy())->find($iterator('bar'))); - $this->assertFalse(Underscore::from($this->getDummy())->find($iterator('foo'))); - } - public function testFilter() { $value = Underscore::from($this->getDummy()) From 35e4a8fa51c988e0ae6b8a513eddb1046df0920d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:28:26 +0300 Subject: [PATCH 06/27] Move has() test to separate file --- tests/Accessor/FindAccessorTest.php | 2 +- tests/Accessor/HasAccessorTest.php | 37 +++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 12 ---------- 3 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 tests/Accessor/HasAccessorTest.php diff --git a/tests/Accessor/FindAccessorTest.php b/tests/Accessor/FindAccessorTest.php index 8e9463e..136a82b 100644 --- a/tests/Accessor/FindAccessorTest.php +++ b/tests/Accessor/FindAccessorTest.php @@ -35,7 +35,7 @@ public function getTestInvokeData() $ret[] = [ true, - [new Collection($this->getDummy2()), $func('bar')], + [new Collection($this->getDummy1()), $func('bar')], ]; return $ret; diff --git a/tests/Accessor/HasAccessorTest.php b/tests/Accessor/HasAccessorTest.php new file mode 100644 index 0000000..5d3874a --- /dev/null +++ b/tests/Accessor/HasAccessorTest.php @@ -0,0 +1,37 @@ +getDummy1()), 'foo'], + ]; + + $ret[] = [ + false, + [new Collection($this->getDummy1()), 'bar'], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index f0af62a..ef2b8ff 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -318,18 +318,6 @@ public function testKeys() ); } - public function testHas() - { - $collection = Underscore::from($this->getDummy()); - - $this->assertTrue($collection->has('name')); - $this->assertTrue($collection->has('foo')); - $this->assertTrue($collection->has('baz')); - - $this->assertFalse($collection->has('nope')); - $this->assertFalse($collection->has('missing')); - } - public function testClone() { $original = $this->getDummy(); From 00a5fe8562a38cf13e18955b2a604cf1785c7a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:30:58 +0300 Subject: [PATCH 07/27] Move max() test to separate file --- tests/Accessor/BaseAccessorTest.php | 14 +++++++++++ tests/Accessor/MaxAccessorTest.php | 37 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/Accessor/MaxAccessorTest.php diff --git a/tests/Accessor/BaseAccessorTest.php b/tests/Accessor/BaseAccessorTest.php index b1996b3..53dfa8a 100644 --- a/tests/Accessor/BaseAccessorTest.php +++ b/tests/Accessor/BaseAccessorTest.php @@ -55,6 +55,20 @@ protected static function getDummy3() return $dummy; } + + /** + * @return object + */ + protected static function getDummy4() + { + $dummy = self::getDummy2(); + $dummy->false = false; + $dummy->null = null; + $dummy->zero = 0; + $dummy->one = 1; + + return $dummy; + } /** * @return Accessor|callable */ diff --git a/tests/Accessor/MaxAccessorTest.php b/tests/Accessor/MaxAccessorTest.php new file mode 100644 index 0000000..824d3ae --- /dev/null +++ b/tests/Accessor/MaxAccessorTest.php @@ -0,0 +1,37 @@ +getDummy2())], + ]; + + $ret[] = [ + 1, + [new Collection($this->getDummy4())], + ]; + + return $ret; + } +} From 55c8e19559f1e2bbe7ca3a2c33c962044150243c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:32:40 +0300 Subject: [PATCH 08/27] Move min() test to separate file --- tests/Accessor/MaxAccessorTest.php | 8 +++---- tests/Accessor/MinAccessorTest.php | 37 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/Accessor/MinAccessorTest.php diff --git a/tests/Accessor/MaxAccessorTest.php b/tests/Accessor/MaxAccessorTest.php index 824d3ae..e7bb8a2 100644 --- a/tests/Accessor/MaxAccessorTest.php +++ b/tests/Accessor/MaxAccessorTest.php @@ -23,13 +23,13 @@ public function getTestInvokeData() $ret = []; $ret[] = [ - 'qux', - [new Collection($this->getDummy2())], + 2, + [new Collection([0, 1, 2])], ]; $ret[] = [ - 1, - [new Collection($this->getDummy4())], + 0, + [new Collection([0, false, 'foo'])], ]; return $ret; diff --git a/tests/Accessor/MinAccessorTest.php b/tests/Accessor/MinAccessorTest.php new file mode 100644 index 0000000..add866f --- /dev/null +++ b/tests/Accessor/MinAccessorTest.php @@ -0,0 +1,37 @@ + Date: Sat, 10 Oct 2015 12:34:25 +0300 Subject: [PATCH 09/27] Move reduce() test to separate file --- tests/Accessor/ReduceAccessorTest.php | 37 +++++++++++++++++++++++++++ tests/UnderscoreTest.php | 15 ----------- 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 tests/Accessor/ReduceAccessorTest.php diff --git a/tests/Accessor/ReduceAccessorTest.php b/tests/Accessor/ReduceAccessorTest.php new file mode 100644 index 0000000..89cfdd3 --- /dev/null +++ b/tests/Accessor/ReduceAccessorTest.php @@ -0,0 +1,37 @@ +getDummy1()), $func], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index ef2b8ff..b514ea3 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -139,21 +139,6 @@ function ($value, $key) use (&$buffer) { ); } - public function testReduce() - { - $value = Underscore::from($this->getDummy()) - ->reduce( - function ($accu, $value) { - $accu .= $value . ' '; - - return $accu; - }, - '' - ); - - $this->assertSame('dummy bar qux ', $value); - } - public function testReduceRight() { $value = Underscore::from($this->getDummy()) From de2675e2896a5af349894f0cb98c91d5fd32d18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:35:25 +0300 Subject: [PATCH 10/27] Move reduceRight() test to separate file --- tests/Accessor/ReduceRightAccessorTest.php | 37 ++++++++++++++++++++++ tests/UnderscoreTest.php | 15 --------- 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 tests/Accessor/ReduceRightAccessorTest.php diff --git a/tests/Accessor/ReduceRightAccessorTest.php b/tests/Accessor/ReduceRightAccessorTest.php new file mode 100644 index 0000000..f831fe3 --- /dev/null +++ b/tests/Accessor/ReduceRightAccessorTest.php @@ -0,0 +1,37 @@ +getDummy1()), $func], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index b514ea3..19a34a9 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -139,21 +139,6 @@ function ($value, $key) use (&$buffer) { ); } - public function testReduceRight() - { - $value = Underscore::from($this->getDummy()) - ->reduceRight( - function ($accumulator, $value) { - $accumulator .= $value . ' '; - - return $accumulator; - }, - '' - ); - - $this->assertSame('qux bar dummy ', $value); - } - public function testPick() { $value = Underscore::from([$this->getDummy(), $this->getDummy(), $this->getDummy()]) From 8b610f2b4860aee915e037246c3c665f7d774785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:37:30 +0300 Subject: [PATCH 11/27] Move toArray() test to separate file --- tests/Accessor/ToArrayAccessorTest.php | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/Accessor/ToArrayAccessorTest.php diff --git a/tests/Accessor/ToArrayAccessorTest.php b/tests/Accessor/ToArrayAccessorTest.php new file mode 100644 index 0000000..372a704 --- /dev/null +++ b/tests/Accessor/ToArrayAccessorTest.php @@ -0,0 +1,37 @@ +getDummy1(), + [new Collection($this->getDummy1())], + ]; + + $ret[] = [ + (array) $this->getDummy2(), + [new Collection($this->getDummy2())], + ]; + + return $ret; + } +} From 922d7c1756bfd4bbd6f46aa1013d87569ec4bf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:41:00 +0300 Subject: [PATCH 12/27] Move value() test to separate file --- src/Accessor/ValueAccessor.php | 3 +++ src/Collection.php | 1 + tests/Accessor/ValueAccessorTest.php | 37 ++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 6 ----- 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 tests/Accessor/ValueAccessorTest.php diff --git a/src/Accessor/ValueAccessor.php b/src/Accessor/ValueAccessor.php index 75cd51c..bb06c95 100644 --- a/src/Accessor/ValueAccessor.php +++ b/src/Accessor/ValueAccessor.php @@ -5,6 +5,9 @@ use Underscore\Accessor; use Underscore\Collection; +/** + * @deprecated Use toArray() instead. Will be removed in later releases + */ class ValueAccessor extends Accessor { /** diff --git a/src/Collection.php b/src/Collection.php index f09ec8c..e059164 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -29,6 +29,7 @@ public function getIteratorReversed() /** * @return mixed + * @deprecated Use toArray() instead. Will be removed in later releases */ public function value() { diff --git a/tests/Accessor/ValueAccessorTest.php b/tests/Accessor/ValueAccessorTest.php new file mode 100644 index 0000000..9383afb --- /dev/null +++ b/tests/Accessor/ValueAccessorTest.php @@ -0,0 +1,37 @@ +getDummy1(), + [new Collection($this->getDummy1())], + ]; + + $ret[] = [ + (array) $this->getDummy2(), + [new Collection($this->getDummy2())], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 19a34a9..e829b7e 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -106,12 +106,6 @@ public function testRange($start, $stop, $step, $expected, $exception = null) ); } - public function testValue() - { - $value = Underscore::from($this->getDummy())->value(); - $this->assertEquals((array)$this->getDummy(), $value); - } - public function testInvoke() { $buffer = ''; From 789e39414f20c02a5dadb673369cedd3105652fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 12:46:41 +0300 Subject: [PATCH 13/27] Move map() test to separate file --- tests/Mutator/BaseMutatorTest.php | 91 +++++++++++++++++++++++++++++++ tests/Mutator/MapMutatorTest.php | 36 ++++++++++++ tests/UnderscoreTest.php | 15 ----- 3 files changed, 127 insertions(+), 15 deletions(-) create mode 100644 tests/Mutator/BaseMutatorTest.php create mode 100644 tests/Mutator/MapMutatorTest.php diff --git a/tests/Mutator/BaseMutatorTest.php b/tests/Mutator/BaseMutatorTest.php new file mode 100644 index 0000000..1edc023 --- /dev/null +++ b/tests/Mutator/BaseMutatorTest.php @@ -0,0 +1,91 @@ +name = 'dummy'; + $dummy->foo = 'bar'; + $dummy->baz = 'qux'; + + return $dummy; + } + + /** + * @return object + */ + protected static function getDummy2() + { + $dummy = self::getDummy1(); + $dummy->false = false; + $dummy->null = null; + $dummy->zero = 0; + + return $dummy; + } + + protected static function getDummy3() + { + $dummy = [ + 'Angela' => [ + 'position' => 'dean', + 'sex' => 'female', + ], + 'Bob' => [ + 'position' => 'janitor', + 'sex' => 'male', + ], + 'Mark' => [ + 'position' => 'teacher', + 'sex' => 'male', + 'tenured' => true, + ], + 'Wendy' => [ + 'position' => 'teacher', + 'sex' => 'female', + 'tenured' => 1, + ], + ]; + + return $dummy; + } + + + /** + * @return object + */ + protected static function getDummy4() + { + $dummy = self::getDummy2(); + $dummy->false = false; + $dummy->null = null; + $dummy->zero = 0; + $dummy->one = 1; + + return $dummy; + } + /** + * @return Mutator|callable + */ + abstract protected function getInstance(); + + /** + * @return mixed[] + */ + abstract public function getTestInvokeData(); + + /** + * @param mixed $expected + * @param mixed $args + * @dataProvider getTestInvokeData + */ + public function testInvoke($expected, $args) + { + $this->assertSame($expected, call_user_func_array($this->getInstance(), $args)->toArray()); + } +} diff --git a/tests/Mutator/MapMutatorTest.php b/tests/Mutator/MapMutatorTest.php new file mode 100644 index 0000000..2195025 --- /dev/null +++ b/tests/Mutator/MapMutatorTest.php @@ -0,0 +1,36 @@ + 'name:dummy', 'foo' => 'foo:bar', 'baz' => 'baz:qux'], + [new Collection($this->getDummy1()), $func], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index e829b7e..cb57add 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,21 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testMap() - { - $value = Underscore::from($this->getDummy()) - ->map( - function ($value, $key) use (&$buffer) { - return sprintf('%s:%s', $key, $value); - } - )->toArray(); - - $this->assertSame( - ['name' => 'name:dummy', 'foo' => 'foo:bar', 'baz' => 'baz:qux'], - $value - ); - } - public function testPick() { $value = Underscore::from([$this->getDummy(), $this->getDummy(), $this->getDummy()]) From d59b0bd8162148877e3423e53136f95f71257ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:07:57 +0300 Subject: [PATCH 14/27] Move pick() test to separate file --- tests/Mutator/PickMutatorTest.php | 38 +++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 18 --------------- 2 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 tests/Mutator/PickMutatorTest.php diff --git a/tests/Mutator/PickMutatorTest.php b/tests/Mutator/PickMutatorTest.php new file mode 100644 index 0000000..9722c1d --- /dev/null +++ b/tests/Mutator/PickMutatorTest.php @@ -0,0 +1,38 @@ +getDummy1(), $this->getDummy1()]), 'foo'], + ]; + + $ret[] = [ + ['foo'], + [new Collection([new Dummy()]), 'getFoo'], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index cb57add..2ea280d 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,24 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testPick() - { - $value = Underscore::from([$this->getDummy(), $this->getDummy(), $this->getDummy()]) - ->pick('foo') - ->toArray(); - - $this->assertSame(['bar', 'bar', 'bar'], $value); - } - - public function testPickGetter() - { - $value = Underscore::from([new Dummy()]) - ->pick('getFoo') - ->toArray(); - - $this->assertSame(['foo'], $value); - } - public function testFilter() { $value = Underscore::from($this->getDummy()) From e44903817bab4b539cad432b945d791e626b02dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:09:56 +0300 Subject: [PATCH 15/27] Move filter() test to separate file --- tests/Mutator/FilterMutatorTest.php | 36 +++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 13 ----------- 2 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 tests/Mutator/FilterMutatorTest.php diff --git a/tests/Mutator/FilterMutatorTest.php b/tests/Mutator/FilterMutatorTest.php new file mode 100644 index 0000000..f70c065 --- /dev/null +++ b/tests/Mutator/FilterMutatorTest.php @@ -0,0 +1,36 @@ + 'dummy'], + [new Collection($this->getDummy1()), $func], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 2ea280d..5c101f0 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,19 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testFilter() - { - $value = Underscore::from($this->getDummy()) - ->filter( - function ($value) { - return 3 < strlen($value); - } - ) - ->toArray(); - - $this->assertSame(['name' => 'dummy'], $value); - } - public function testReject() { $value = Underscore::from($this->getDummy()) From 592c0ac6f00189ed8a167bc5ad97b15d6b22f233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:10:12 +0300 Subject: [PATCH 16/27] Move reject() test to separate file --- tests/Mutator/RejectMutatorTest.php | 36 +++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 13 ----------- 2 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 tests/Mutator/RejectMutatorTest.php diff --git a/tests/Mutator/RejectMutatorTest.php b/tests/Mutator/RejectMutatorTest.php new file mode 100644 index 0000000..23c90b7 --- /dev/null +++ b/tests/Mutator/RejectMutatorTest.php @@ -0,0 +1,36 @@ + 'bar', 'baz' => 'qux'], + [new Collection($this->getDummy1()), $func], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 5c101f0..c816003 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,19 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testReject() - { - $value = Underscore::from($this->getDummy()) - ->reject( - function ($value) { - return 3 < strlen($value); - } - ) - ->toArray(); - - $this->assertSame(['foo' => 'bar', 'baz' => 'qux'], $value); - } - public function testHead() { $value = Underscore::from($this->getDummy()) From 32f873bff2334956ec60890a17642186cfbd27d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:11:51 +0300 Subject: [PATCH 17/27] Move head() test to separate file --- tests/Mutator/HeadMutatorTest.php | 32 +++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 9 --------- 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 tests/Mutator/HeadMutatorTest.php diff --git a/tests/Mutator/HeadMutatorTest.php b/tests/Mutator/HeadMutatorTest.php new file mode 100644 index 0000000..3de26d0 --- /dev/null +++ b/tests/Mutator/HeadMutatorTest.php @@ -0,0 +1,32 @@ + 'dummy', 'foo' => 'bar'], + [new Collection($this->getDummy1()), 2], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index c816003..8a7e123 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,15 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testHead() - { - $value = Underscore::from($this->getDummy()) - ->head(2) - ->value(); - - $this->assertSame(['name' => 'dummy', 'foo' => 'bar'], $value); - } - public function testTail() { $value = Underscore::from($this->getDummy()) From 8d3040e8d27a7b9938b5f8927c14216b20c0066f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:13:11 +0300 Subject: [PATCH 18/27] Move tail() test to separate file --- tests/Mutator/TailMutatorTest.php | 32 +++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 9 --------- 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 tests/Mutator/TailMutatorTest.php diff --git a/tests/Mutator/TailMutatorTest.php b/tests/Mutator/TailMutatorTest.php new file mode 100644 index 0000000..d468c73 --- /dev/null +++ b/tests/Mutator/TailMutatorTest.php @@ -0,0 +1,32 @@ + 'bar', 'baz' => 'qux'], + [new Collection($this->getDummy1()), 1], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 8a7e123..1864a32 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,15 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testTail() - { - $value = Underscore::from($this->getDummy()) - ->tail(1) - ->value(); - - $this->assertSame(['foo' => 'bar', 'baz' => 'qux'], $value); - } - public function testInitial() { $value = Underscore::from($this->getDummy()) From cfebdbcf673b302a10a9868dee202735c0696ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:14:16 +0300 Subject: [PATCH 19/27] Move initial() test to separate file --- tests/Mutator/InitialMutatorTest.php | 32 ++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 9 -------- 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 tests/Mutator/InitialMutatorTest.php diff --git a/tests/Mutator/InitialMutatorTest.php b/tests/Mutator/InitialMutatorTest.php new file mode 100644 index 0000000..9dcbfea --- /dev/null +++ b/tests/Mutator/InitialMutatorTest.php @@ -0,0 +1,32 @@ + 'dummy'], + [new Collection($this->getDummy1()), 2], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 1864a32..db69a4b 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,15 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testInitial() - { - $value = Underscore::from($this->getDummy()) - ->initial(2) - ->value(); - - $this->assertSame(['name' => 'dummy'], $value); - } - public function testLast() { $value = Underscore::from($this->getDummy()) From 1faf3a6f9b775b255d9f6f39da005e213b36ebb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:15:54 +0300 Subject: [PATCH 20/27] Move last() test to separate file --- tests/Mutator/LastMutatorTest.php | 32 +++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 9 --------- 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 tests/Mutator/LastMutatorTest.php diff --git a/tests/Mutator/LastMutatorTest.php b/tests/Mutator/LastMutatorTest.php new file mode 100644 index 0000000..35b09ed --- /dev/null +++ b/tests/Mutator/LastMutatorTest.php @@ -0,0 +1,32 @@ + 'bar', 'baz' => 'qux'], + [new Collection($this->getDummy1()), 2], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index db69a4b..ee61223 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -118,15 +118,6 @@ function ($value, $key) use (&$buffer) { $this->assertSame('name:dummy|foo:bar|baz:qux|', $buffer); } - public function testLast() - { - $value = Underscore::from($this->getDummy()) - ->last(2) - ->value(); - - $this->assertSame(['foo' => 'bar', 'baz' => 'qux'], $value); - } - public function testCompact() { $value = Underscore::from($this->getDummy2()) From 030ff627a5bdc5efc22037ccbe99ef6dde81cc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:18:18 +0300 Subject: [PATCH 21/27] Move without() test to separate file --- tests/Mutator/WithoutMutatorTest.php | 32 ++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 9 -------- 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 tests/Mutator/WithoutMutatorTest.php diff --git a/tests/Mutator/WithoutMutatorTest.php b/tests/Mutator/WithoutMutatorTest.php new file mode 100644 index 0000000..265df36 --- /dev/null +++ b/tests/Mutator/WithoutMutatorTest.php @@ -0,0 +1,32 @@ + 'bar', 'baz' => 'qux'], + [new Collection($this->getDummy1()), ['dummy']], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index ee61223..2dedd1e 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -127,15 +127,6 @@ public function testCompact() $this->assertSame(['name' => 'dummy', 'foo' => 'bar', 'baz' => 'qux'], $value); } - public function testWithout() - { - $value = Underscore::from($this->getDummy()) - ->without(['dummy']) - ->toArray(); - - $this->assertSame(['foo' => 'bar', 'baz' => 'qux'], $value); - } - public function testMerge() { $value = Underscore::from($this->getDummy()) From 56f4753fd08479126477b6d445e2501dbc87e2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:21:49 +0300 Subject: [PATCH 22/27] Move merge() test to separate file --- tests/Mutator/MergeMutatorTest.php | 39 ++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 19 --------------- 2 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 tests/Mutator/MergeMutatorTest.php diff --git a/tests/Mutator/MergeMutatorTest.php b/tests/Mutator/MergeMutatorTest.php new file mode 100644 index 0000000..18b3f30 --- /dev/null +++ b/tests/Mutator/MergeMutatorTest.php @@ -0,0 +1,39 @@ + 'dummy', + 'foo' => 'bar', + 'baz' => 'qux', + 'false' => false, + 'null' => null, + 'zero' => 0, + ], + [new Collection($this->getDummy1()), new Collection($this->getDummy2())], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 2dedd1e..1120bce 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -127,25 +127,6 @@ public function testCompact() $this->assertSame(['name' => 'dummy', 'foo' => 'bar', 'baz' => 'qux'], $value); } - public function testMerge() - { - $value = Underscore::from($this->getDummy()) - ->merge(new Collection($this->getDummy2())) - ->toArray(); - - $this->assertSame( - [ - 'name' => 'dummy', - 'foo' => 'bar', - 'baz' => 'qux', - 'false' => false, - 'null' => null, - 'zero' => 0, - ], - $value - ); - } - public function testValues() { $value = Underscore::from($this->getDummy()) From 85bb4d9c6fcfed4fa1d7efe538ee682a76eeb3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:22:52 +0300 Subject: [PATCH 23/27] Move values() test to separate file --- tests/Mutator/ValuesMutatorTest.php | 32 +++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 16 --------------- 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 tests/Mutator/ValuesMutatorTest.php diff --git a/tests/Mutator/ValuesMutatorTest.php b/tests/Mutator/ValuesMutatorTest.php new file mode 100644 index 0000000..865f108 --- /dev/null +++ b/tests/Mutator/ValuesMutatorTest.php @@ -0,0 +1,32 @@ +getDummy1())], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 1120bce..ca38953 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -127,22 +127,6 @@ public function testCompact() $this->assertSame(['name' => 'dummy', 'foo' => 'bar', 'baz' => 'qux'], $value); } - public function testValues() - { - $value = Underscore::from($this->getDummy()) - ->values() - ->toArray(); - - $this->assertSame( - [ - 'dummy', - 'bar', - 'qux', - ], - $value - ); - } - public function testKeys() { $value = Underscore::from($this->getDummy()) From 6a968139f2270c88a28146c4439a4f5ddfbc4fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:23:39 +0300 Subject: [PATCH 24/27] Move keys() test to separate file --- tests/Mutator/KeysMutatorTest.php | 32 +++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 16 ---------------- 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 tests/Mutator/KeysMutatorTest.php diff --git a/tests/Mutator/KeysMutatorTest.php b/tests/Mutator/KeysMutatorTest.php new file mode 100644 index 0000000..d78b95d --- /dev/null +++ b/tests/Mutator/KeysMutatorTest.php @@ -0,0 +1,32 @@ +getDummy1())], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index ca38953..fd00781 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -127,22 +127,6 @@ public function testCompact() $this->assertSame(['name' => 'dummy', 'foo' => 'bar', 'baz' => 'qux'], $value); } - public function testKeys() - { - $value = Underscore::from($this->getDummy()) - ->keys() - ->toArray(); - - $this->assertSame( - [ - 'name', - 'foo', - 'baz', - ], - $value - ); - } - public function testClone() { $original = $this->getDummy(); From cea9372bcad3fa0a65843399b3a0d2600d16c16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:27:39 +0300 Subject: [PATCH 25/27] Move zip() test to separate file --- tests/Mutator/ZipMutatorTest.php | 44 ++++++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 20 --------------- 2 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 tests/Mutator/ZipMutatorTest.php diff --git a/tests/Mutator/ZipMutatorTest.php b/tests/Mutator/ZipMutatorTest.php new file mode 100644 index 0000000..5e75ef5 --- /dev/null +++ b/tests/Mutator/ZipMutatorTest.php @@ -0,0 +1,44 @@ + 'dummy', + 1 => 'bar', + '42' => 'qux', + ], + [new Collection($this->getDummy1()), ['a', 1, '42']], + ]; + + return $ret; + } + + /** + * @expectedException \LogicException + */ + public function testThrowIfWrongDimmensions() + { + $this->getInstance()->__invoke(new Collection($this->getDummy1()), ['a']); + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index fd00781..f2df7f3 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -141,26 +141,6 @@ public function testClone() ); } - public function testZip() - { - $value = Underscore::from($this->getDummy()) - ->zip(['a', 1, '42']) - ->toArray(); - - $this->assertSame( - [ - 'a' => 'dummy', - 1 => 'bar', - '42' => 'qux', - ], - $value - ); - - $this->setExpectedException('\LogicException'); - Underscore::from($this->getDummy()) - ->zip(['a']); - } - public function testGroupBy() { $value = Underscore::from($this->getDummy()) From 10cbf208db067db04c9adfc3dc98d0441860b9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:28:38 +0300 Subject: [PATCH 26/27] Move groupBy() test to separate file --- tests/Mutator/GroupByMutatorTest.php | 35 ++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 15 ------------ 2 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 tests/Mutator/GroupByMutatorTest.php diff --git a/tests/Mutator/GroupByMutatorTest.php b/tests/Mutator/GroupByMutatorTest.php new file mode 100644 index 0000000..aa61a92 --- /dev/null +++ b/tests/Mutator/GroupByMutatorTest.php @@ -0,0 +1,35 @@ + ['dummy'], + 3 => ['bar', 'qux'], + ], + [new Collection($this->getDummy1()), 'strlen'], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index f2df7f3..93878ce 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -141,21 +141,6 @@ public function testClone() ); } - public function testGroupBy() - { - $value = Underscore::from($this->getDummy()) - ->groupBy('strlen') - ->toArray(); - - $this->assertSame( - [ - 5 => ['dummy'], - 3 => ['bar', 'qux'], - ], - $value - ); - } - public function testSortBy() { $value = Underscore::from($this->getDummy()) From 98051e6d62973e9f7e8f0288f5e908fe35c21a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurynas=20Ver=C5=BEukauskas?= Date: Sat, 10 Oct 2015 13:29:47 +0300 Subject: [PATCH 27/27] Move sortBy() test to separate file --- tests/Mutator/SortByMutatorTest.php | 32 +++++++++++++++++++++++++++++ tests/UnderscoreTest.php | 16 --------------- 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 tests/Mutator/SortByMutatorTest.php diff --git a/tests/Mutator/SortByMutatorTest.php b/tests/Mutator/SortByMutatorTest.php new file mode 100644 index 0000000..45d6468 --- /dev/null +++ b/tests/Mutator/SortByMutatorTest.php @@ -0,0 +1,32 @@ +getDummy1()), 'strlen'], + ]; + + return $ret; + } +} diff --git a/tests/UnderscoreTest.php b/tests/UnderscoreTest.php index 93878ce..951eb02 100644 --- a/tests/UnderscoreTest.php +++ b/tests/UnderscoreTest.php @@ -141,22 +141,6 @@ public function testClone() ); } - public function testSortBy() - { - $value = Underscore::from($this->getDummy()) - ->sortBy('strlen') - ->toArray(); - - $this->assertSame( - [ - 'bar', - 'qux', - 'dummy', - ], - $value - ); - } - /** * @return array */