You are here

public function DisableCurrencyTest::testExecute in Currency 8.3

@covers ::execute

File

tests/src/Unit/Controller/DisableCurrencyTest.php, line 62

Class

DisableCurrencyTest
@coversDefaultClass \Drupal\currency\Controller\DisableCurrency

Namespace

Drupal\Tests\currency\Unit\Controller

Code

public function testExecute() {
  $url = $this
    ->randomMachineName();
  $currency = $this
    ->createMock(CurrencyInterface::class);
  $currency
    ->expects($this
    ->once())
    ->method('disable');
  $currency
    ->expects($this
    ->once())
    ->method('save');
  $this->urlGenerator
    ->expects($this
    ->once())
    ->method('generateFromRoute')
    ->with('entity.currency.collection')
    ->willReturn($url);
  $response = $this->sut
    ->execute($currency);
  $this
    ->assertInstanceOf(RedirectResponse::class, $response);
  $this
    ->assertSame($url, $response
    ->getTargetUrl());
}