You are here

class PhotosAlbumTest in Album Photos 8.5

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/PhotosAlbumTest.php \Drupal\Tests\photos\Unit\PhotosAlbumTest
  2. 6.0.x tests/src/Unit/PhotosAlbumTest.php \Drupal\Tests\photos\Unit\PhotosAlbumTest

@coversDefaultClass \Drupal\photos\PhotosAlbum @group photos

Hierarchy

  • class \Drupal\Tests\photos\Unit\PhotosAlbumTest extends \PHPUnit\Framework\TestCase

Expanded class hierarchy of PhotosAlbumTest

File

tests/src/Unit/PhotosAlbumTest.php, line 12

Namespace

Drupal\Tests\photos\Unit
View source
class PhotosAlbumTest extends TestCase {

  /**
   * Data provider for testOrderValueChange.
   */
  public function orderValueChangeProvider() {
    return [
      [
        'weight',
        'asc',
        [
          'column' => 'p.weight',
          'sort' => 'asc',
        ],
      ],
      [
        'filesize',
        'asc',
        [
          'column' => 'f.filesize',
          'sort' => 'asc',
        ],
      ],
      [
        'test',
        'test',
        [
          'column' => 'p.id',
          'sort' => 'desc',
        ],
      ],
    ];
  }

  /**
   * @covers ::orderValueChange
   * @dataProvider orderValueChangeProvider
   */
  public function testOrderValueChange($field, $sort, $expected_result) {
    $this
      ->assertSame($expected_result, PhotosAlbum::orderValueChange($field, $sort));
  }

  /**
   * Data provider for testOrderValue.
   */
  public function orderValueProvider() {
    return [
      [
        'weight',
        'asc',
        0,
        0,
        [
          'order' => [
            'column' => 'p.weight',
            'sort' => 'asc',
          ],
        ],
      ],
      [
        0,
        0,
        0,
        [
          'column' => 'f.filesize',
          'sort' => 'asc',
        ],
        [
          'order' => [
            'column' => 'f.filesize',
            'sort' => 'asc',
          ],
        ],
      ],
      [
        0,
        0,
        0,
        0,
        [
          'order' => [
            'column' => 'p.id',
            'sort' => 'desc',
          ],
        ],
      ],
    ];
  }

  /**
   * @covers ::orderValue
   * @dataProvider orderValueProvider
   */
  public function testOrderValue($field, $sort, $limit, $default, $expected_result) {
    $this
      ->assertSame($expected_result, PhotosAlbum::orderValue($field, $sort, $limit, $default));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhotosAlbumTest::orderValueChangeProvider public function Data provider for testOrderValueChange.
PhotosAlbumTest::orderValueProvider public function Data provider for testOrderValue.
PhotosAlbumTest::testOrderValue public function @covers ::orderValue @dataProvider orderValueProvider
PhotosAlbumTest::testOrderValueChange public function @covers ::orderValueChange @dataProvider orderValueChangeProvider