From 2586d4d3ffbde0212b0e7c8f5c706d15fbf3ab64 Mon Sep 17 00:00:00 2001 From: Max Almonte Date: Wed, 26 Sep 2018 14:56:25 -0400 Subject: [PATCH] Updated tests to work with new API --- tests/Unit/ArrayListTest.php | 6 +++--- tests/Unit/DictionaryTest.php | 13 +++++-------- tests/Unit/GenericListTest.php | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/Unit/ArrayListTest.php b/tests/Unit/ArrayListTest.php index 1fc971a..c05f8c5 100644 --- a/tests/Unit/ArrayListTest.php +++ b/tests/Unit/ArrayListTest.php @@ -2,7 +2,7 @@ namespace Tests\Unit; -use \StdClass; +use StdClass; use PHPUnit\Framework\TestCase; use PHPCollections\Collections\ArrayList; @@ -170,9 +170,9 @@ public function cannotUpdateAnNonExistingValue() /** @test */ public function canIterateOverEachElement() { - $this->arrayList->forEach(function ($value, $key) { + $this->arrayList->forEach(function (&$value, $key) { if (!is_object($value) && $value) { - $this->arrayList->update($key, $value . 'x'); + $value = $value.'x'; } }); diff --git a/tests/Unit/DictionaryTest.php b/tests/Unit/DictionaryTest.php index 16bd56f..2f2a382 100644 --- a/tests/Unit/DictionaryTest.php +++ b/tests/Unit/DictionaryTest.php @@ -8,7 +8,6 @@ class DictionaryTest extends TestCase { - private $dictionary; public function setUp() @@ -82,7 +81,6 @@ public function canUpdateDataByMapping() }); $this->assertInstanceOf(Dictionary::class, $newDictionary); - $this->assertArrayHasKey('smoke', $newDictionary); $this->assertEquals('no', $newDictionary->get('smoke')); } @@ -201,19 +199,18 @@ public function canGetValueType() /** @test */ public function canSortByGivenRules() { - $sorted = $this->dictionary->sort(function ($x, $y) { - return strlen($x->getValue()) <=> strlen($y->getValue()); + $sortedDictionary = $this->dictionary->sort(function ($x, $y) { + return strlen($x) <=> strlen($y); }); - $this->assertTrue($sorted); - $this->assertEquals('a little bit', $this->dictionary->last()); + $this->assertEquals('a little bit', $sortedDictionary->last()); } /** @test */ public function canIterateOverEachElement() { - $this->dictionary->forEach(function ($pair, $key) { - $pair->setValue($pair->getValue($key) . 'x'); + $this->dictionary->forEach(function (&$value, $key) { + $value = $value . 'x'; }); $this->assertEquals('Maxx', $this->dictionary->get('name')); diff --git a/tests/Unit/GenericListTest.php b/tests/Unit/GenericListTest.php index 0b77549..624c7a7 100644 --- a/tests/Unit/GenericListTest.php +++ b/tests/Unit/GenericListTest.php @@ -2,8 +2,8 @@ namespace Tests\Unit; -use \Exception; -use \ArrayObject; +use Exception; +use ArrayObject; use PHPUnit\Framework\TestCase; use PHPCollections\Collections\GenericList;