function BookManagerTest::providerTestGetBookParents

Same name and namespace in other branches
  1. 9 core/modules/book/tests/src/Unit/BookManagerTest.php \Drupal\Tests\book\Unit\BookManagerTest::providerTestGetBookParents()
  2. 8.9.x core/modules/book/tests/src/Unit/BookManagerTest.php \Drupal\Tests\book\Unit\BookManagerTest::providerTestGetBookParents()
  3. 10 core/modules/book/tests/src/Unit/BookManagerTest.php \Drupal\Tests\book\Unit\BookManagerTest::providerTestGetBookParents()

Provides test data for testGetBookParents.

Return value

array The test data.

File

core/modules/book/tests/src/Unit/BookManagerTest.php, line 107

Class

BookManagerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21book%21src%21BookManager.php/class/BookManager/11.x" title="Defines a book manager." class="local">\Drupal\book\BookManager</a> @group book

Namespace

Drupal\Tests\book\Unit

Code

public static function providerTestGetBookParents() {
    $empty = [
        'p1' => 0,
        'p2' => 0,
        'p3' => 0,
        'p4' => 0,
        'p5' => 0,
        'p6' => 0,
        'p7' => 0,
        'p8' => 0,
        'p9' => 0,
    ];
    return [
        // Provides a book without an existing parent.
[
            [
                'pid' => 0,
                'nid' => 12,
            ],
            [],
            [
                'depth' => 1,
                'p1' => 12,
            ] + $empty,
        ],
        // Provides a book with an existing parent.
[
            [
                'pid' => 11,
                'nid' => 12,
            ],
            [
                'nid' => 11,
                'depth' => 1,
                'p1' => 11,
            ],
            [
                'depth' => 2,
                'p1' => 11,
                'p2' => 12,
            ] + $empty,
        ],
        // Provides a book with two existing parents.
[
            [
                'pid' => 11,
                'nid' => 12,
            ],
            [
                'nid' => 11,
                'depth' => 2,
                'p1' => 10,
                'p2' => 11,
            ],
            [
                'depth' => 3,
                'p1' => 10,
                'p2' => 11,
                'p3' => 12,
            ] + $empty,
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.