currency-8.x-3.3/tests/src/Unit/EventDispatcherTest.php

tests/src/Unit/EventDispatcherTest.php
<?php

namespace Drupal\Tests\currency\Unit;

use Drupal\currency\Event\CurrencyEvents;
use Drupal\currency\Event\ResolveCountryCode;
use Drupal\currency\EventDispatcher;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 * Tests the event dispatcher service.
 *
 * @coversDefaultClass \Drupal\currency\EventDispatcher
 *
 * @group Currency
 */
class EventDispatcherTest extends UnitTestCase {

  /**
   * The Symfony event dispatcher.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $symfonyEventDispatcher;

  /**
   * The class under test.
   *
   * @var \Drupal\currency\EventDispatcher
   */
  protected $sut;

  /**
   * {@inheritdoc}
   */
  public function setUp(): void {
    parent::setUp();

    $this->symfonyEventDispatcher = $this->createMock(EventDispatcherInterface::class);

    $this->sut = new EventDispatcher($this->symfonyEventDispatcher);
  }

  /**
   * @covers ::resolveCountryCode
   */
  public function testResolveCountryCode() {
    $this->symfonyEventDispatcher->expects($this->once())
      ->method('dispatch')
      ->with($this->isInstanceOf(ResolveCountryCode::class), CurrencyEvents::RESOLVE_COUNTRY_CODE);

    $this->sut->resolveCountryCode();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc