summaryrefslogtreecommitdiffstats
path: root/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php
blob: 89d0cc1bf5635dcb842bced23f0d894019317e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
 * @file
 * Definition of Drupal\breakpoint\Tests\BreakpointTestBase.
 */

namespace Drupal\breakpoint\Tests;

use Drupal\simpletest\WebTestBase;
use Drupal\breakpoint\Entity\Breakpoint;

/**
 * Base class for Breakpoint tests.
 */
abstract class BreakpointTestBase extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('breakpoint');

  public function setUp() {
    parent::setUp();
  }

  /**
   * Verify that a breakpoint is properly stored.
   */
  public function verifyBreakpoint(Breakpoint $breakpoint, Breakpoint $compare_breakpoint = NULL) {
    $properties = array(
      'label',
      'mediaQuery',
      'source',
      'sourceType',
      'weight',
      'multipliers',
    );

    // Verify breakpoint_load().
    $compare_breakpoint = is_null($compare_breakpoint) ? breakpoint_load($breakpoint->id()) : $compare_breakpoint;
    foreach ($properties as $property) {
      $t_args = array(
        '%breakpoint' => $breakpoint->label(),
        '%property' => $property,
      );
      $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('breakpoint_load: Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API');
    }
  }
}