Skip to content

Commit

Permalink
Updated tests to work with new API
Browse files Browse the repository at this point in the history
  • Loading branch information
maxalmonte14 committed Sep 26, 2018
1 parent f94f6a2 commit 2586d4d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tests/Unit/ArrayListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Unit;

use \StdClass;
use StdClass;
use PHPUnit\Framework\TestCase;
use PHPCollections\Collections\ArrayList;

Expand Down Expand Up @@ -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';
}
});

Expand Down
13 changes: 5 additions & 8 deletions tests/Unit/DictionaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class DictionaryTest extends TestCase
{

private $dictionary;

public function setUp()
Expand Down Expand Up @@ -82,7 +81,6 @@ public function canUpdateDataByMapping()
});

$this->assertInstanceOf(Dictionary::class, $newDictionary);
$this->assertArrayHasKey('smoke', $newDictionary);
$this->assertEquals('no', $newDictionary->get('smoke'));
}

Expand Down Expand Up @@ -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'));
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/GenericListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Tests\Unit;

use \Exception;
use \ArrayObject;
use Exception;
use ArrayObject;
use PHPUnit\Framework\TestCase;
use PHPCollections\Collections\GenericList;

Expand Down

0 comments on commit 2586d4d

Please sign in to comment.