You are here

class MixItUpDefaultOptionsServiceTest in MixItUp Views 8.2

Same name and namespace in other branches
  1. 8 tests/src/Unit/MixItUpDefaultOptionsServiceTest.php \Drupal\Tests\mixitup_views\Unit\MixItUpDefaultOptionsServiceTest

Class MixItUpDefaultOptionsServiceTest.

@group MixItUp Views @package Drupal\Tests\mixitup_views\Unit

Hierarchy

Expanded class hierarchy of MixItUpDefaultOptionsServiceTest

File

tests/src/Unit/MixItUpDefaultOptionsServiceTest.php, line 14

Namespace

Drupal\Tests\mixitup_views\Unit
View source
class MixItUpDefaultOptionsServiceTest extends UnitTestCase {

  /**
   * The MixitupViewsDefaultOptionsService instance.
   *
   * @var \Drupal\mixitup_views\MixitupViewsDefaultOptionsService
   */
  protected $unit;

  /**
   * Before a test method is run, setUp() is invoked.
   *
   * Create new unit object.
   */
  public function setUp() {
    $this->unit = new MixitupViewsDefaultOptionsService();
  }

  /**
   * Covers defaultOptions method if $convert param coming with a FALSE value.
   *
   * @covers \Drupal\mixitup_views\MixitupViewsDefaultOptionsService::defaultOptions
   */
  public function testDefaultOptionsFalse() : void {
    $options = [
      'selectors' => [
        'target' => '.mix',
        'filter' => '.filter',
        'sort' => '.sort',
      ],
      'load' => [
        'filter' => 'all',
        'sort' => 'default:asc',
      ],
      'animation' => [
        'enable' => TRUE,
        'effects' => 'fade scale',
        'duration' => 600,
        'easing' => 'ease',
        'perspectiveDistance' => '3000px',
        'perspectiveOrigin' => '50% 50%',
        'queue' => TRUE,
        'queueLimit' => 1,
      ],
      'restrict' => [
        'vocab' => FALSE,
        'vocab_ids' => [],
      ],
    ];
    $this
      ->assertEquals($options, $this->unit
      ->defaultOptions(NULL));
  }

  /**
   * Covers defaultOptions method if $convert param coming with a TRUE value.
   *
   * @covers \Drupal\mixitup_views\MixitupViewsDefaultOptionsService::defaultOptions
   */
  public function testDefaultOptionsTrue() : void {
    $options = [
      'selectors_target' => '.mix',
      'selectors_filter' => '.filter',
      'selectors_sort' => '.sort',
      'load_filter' => 'all',
      'load_sort' => 'default:asc',
      'animation_enable' => TRUE,
      'animation_effects' => 'fade scale',
      'animation_duration' => 600,
      'animation_easing' => 'ease',
      'animation_perspectiveDistance' => '3000px',
      'animation_perspectiveOrigin' => '50% 50%',
      'animation_queue' => TRUE,
      'animation_queueLimit' => 1,
      'restrict_vocab' => FALSE,
      'restrict_vocab_ids' => [],
    ];
    $this
      ->assertEquals($options, $this->unit
      ->defaultOptions(TRUE));
  }

  /**
   * If test has finished running, tearDown() will be invoked.
   *
   * Unset the $unit object.
   */
  public function tearDown() {
    unset($this->unit);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MixItUpDefaultOptionsServiceTest::$unit protected property The MixitupViewsDefaultOptionsService instance.
MixItUpDefaultOptionsServiceTest::setUp public function Before a test method is run, setUp() is invoked. Overrides UnitTestCase::setUp
MixItUpDefaultOptionsServiceTest::tearDown public function If test has finished running, tearDown() will be invoked.
MixItUpDefaultOptionsServiceTest::testDefaultOptionsFalse public function Covers defaultOptions method if $convert param coming with a FALSE value.
MixItUpDefaultOptionsServiceTest::testDefaultOptionsTrue public function Covers defaultOptions method if $convert param coming with a TRUE value.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.