summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Iterators/AppendIteratorTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Iterators/AppendIteratorTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Iterators/AppendIteratorTest.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Iterators/AppendIteratorTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Iterators/AppendIteratorTest.php
new file mode 100644
index 00000000..617d244f
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Iterators/AppendIteratorTest.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace SMW\Tests\Iterators;
+
+use SMW\Iterators\AppendIterator;
+use SMW\Tests\PHPUnitCompat;
+
+/**
+ * @covers \SMW\Iterators\AppendIterator
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 3.0
+ *
+ * @author mwjames
+ */
+class AppendIteratorTest extends \PHPUnit_Framework_TestCase {
+
+ use PHPUnitCompat;
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ AppendIterator::class,
+ new AppendIterator()
+ );
+ }
+
+ /**
+ * @dataProvider iterableProvider
+ */
+ public function testCount( $iterable, $expected ) {
+
+ $instance = new AppendIterator();
+ $instance->add( $iterable );
+
+ $this->assertEquals(
+ $expected,
+ $instance->count()
+ );
+ }
+
+ public function testAddOnNonIterableThrowsException() {
+
+ $instance = new AppendIterator();
+
+ $this->setExpectedException( 'RuntimeException' );
+ $instance->add( 'Foo' );
+ }
+
+ public function iterableProvider() {
+
+ $provider[] = [
+ [
+ 1, 42, 1001, 9999
+ ],
+ 4
+ ];
+
+ $iterator = new AppendIterator();
+ $iterator->add( [ 0 , 1 ] );
+
+ $provider[] = [
+ $iterator,
+ 2
+ ];
+
+ $iterator = new AppendIterator();
+ $iterator->add( [ 0 , 1 ] );
+ $iterator->add( $iterator );
+
+ $provider[] = [
+ $iterator,
+ 4
+ ];
+
+ return $provider;
+ }
+
+}