summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateu Aguiló Bosch2017-09-12 20:09:27 +0200
committerMateu Aguiló Bosch2017-09-12 20:09:27 +0200
commit5a389ac8097b9f90440836d8c07a5020e7404af1 (patch)
tree782f3b76180efed665429844b90f0d80bd773dd1
parentb9c94653d8e591f9d0c67ce55baf3b1559285b3b (diff)
test(Misc): Add test coverage to the SubrequestsTree8.x-2.0-beta18.x-2.0-alpha1
-rw-r--r--tests/src/Unit/SubrequestsTreeTest.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/src/Unit/SubrequestsTreeTest.php b/tests/src/Unit/SubrequestsTreeTest.php
new file mode 100644
index 0000000..daee7e6
--- /dev/null
+++ b/tests/src/Unit/SubrequestsTreeTest.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\Tests\subrequests\Unit;
+
+use Drupal\subrequests\Subrequest;
+use Drupal\subrequests\SubrequestsTree;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * @coversDefaultClass \Drupal\subrequests\SubrequestsTree
+ * @group subrequests
+ */
+class SubrequestsTreeTest extends UnitTestCase {
+
+ /**
+ * @dataProvider dataProviderStack
+ * @covers ::stack
+ * @covers ::getLowestLevel
+ * @covers ::getNumLevels
+ */
+ public function testStack($input, $expected_count) {
+ $sut = new SubrequestsTree();
+ $sut->stack($input);
+ $this->assertSame(1, $sut->getNumLevels());
+ $this->assertSame($expected_count, count($sut->getLowestLevel()));
+ }
+
+ public function dataProviderStack() {
+ $defaults = [
+ 'requestId' => 1,
+ 'body' => '',
+ 'headers' => [],
+ 'waitFor' => 1,
+ '_resolved' => FALSE,
+ 'uri' => '',
+ 'action' => '',
+ ];
+ return [
+ [[new Subrequest($defaults), 12, new Subrequest($defaults)], 2],
+ [[12], 0],
+ ];
+ }
+
+}