You are here

DefaultStoreResolverTest.php in Commerce Core 8.2

File

modules/store/tests/src/Unit/Resolver/DefaultStoreResolverTest.php
View source
<?php

namespace Drupal\Tests\commerce_store\Unit\Resolver;

use Drupal\commerce_store\Resolver\DefaultStoreResolver;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\commerce_store\Resolver\DefaultStoreResolver
 * @group commerce_store
 */
class DefaultStoreResolverTest extends UnitTestCase {

  /**
   * The resolver.
   *
   * @var \Drupal\commerce_store\Resolver\DefaultStoreResolver
   */
  protected $resolver;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    $storage = $this
      ->getMockBuilder('Drupal\\commerce_store\\StoreStorage')
      ->disableOriginalConstructor()
      ->getMock();
    $storage
      ->expects($this
      ->once())
      ->method('loadDefault')
      ->willReturn('testStore');
    $entity_type_manager = $this
      ->getMockBuilder('\\Drupal\\Core\\Entity\\EntityTypeManager')
      ->disableOriginalConstructor()
      ->getMock();
    $entity_type_manager
      ->expects($this
      ->once())
      ->method('getStorage')
      ->with('commerce_store')
      ->willReturn($storage);
    $this->resolver = new DefaultStoreResolver($entity_type_manager);
  }

  /**
   * @covers ::resolve
   */
  public function testResolve() {
    $this
      ->assertEquals('testStore', $this->resolver
      ->resolve());
  }

}

Classes

Namesort descending Description
DefaultStoreResolverTest @coversDefaultClass \Drupal\commerce_store\Resolver\DefaultStoreResolver @group commerce_store