-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New function iterable_to_traversable()
- Loading branch information
1 parent
a48bd24
commit b5f1cf5
Showing
4 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class TestIterableToTraversable extends TestCase | ||
{ | ||
|
||
public function testFunctionExists() | ||
{ | ||
$this->assertTrue(function_exists('iterable_to_traversable')); | ||
} | ||
|
||
public function testIteratorToTraversable() | ||
{ | ||
$iterator = new ArrayIterator(array('foo' => 'bar')); | ||
$traversable = iterable_to_traversable($iterator); | ||
$this->assertSame($iterator, $traversable); | ||
$this->assertInstanceOf('Traversable', $iterator); | ||
} | ||
|
||
public function testArrayToTraversable() | ||
{ | ||
$array = array('foo' => 'bar'); | ||
$traversable = iterable_to_traversable($array); | ||
$this->assertEquals(new ArrayIterator(array('foo' => 'bar')), $traversable); | ||
$this->assertInstanceOf('Traversable', $traversable); | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testInvalidArgument() | ||
{ | ||
$string = 'foo'; | ||
iterable_to_traversable($string); | ||
var_dump(iterable_to_traversable(array('foo', 'bar'))); | ||
} | ||
} |