Skip to content
Snippets Groups Projects

Resolve #3455292 "Automated drupal 11"

Merged Douglas Groene requested to merge 8.x-1.x into 3.0.x
3 files
+ 18
15
Compare changes
  • Side-by-side
  • Inline
Files
3
<?php
/**
* Unit Tests for the RedirectDatabaseStorage class.
* User: rsimmons
* Date: 10/12/17
* Time: 2:36 PM
* PHPUnit_Framework_TestCase
*/
namespace Drupal\Tests\redirect_extensions\Unit;
use Prophecy\PhpUnit\ProphecyTrait;
use Drupal\redirect_extensions\RedirectDatabaseStorage;
use Drupal\Core\Database\Driver\mysql\Connection;
use Drupal\mysql\Driver\Database\mysql\Connection;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\Session\AccountInterface;
@@ -18,7 +12,7 @@ use Drupal\Component\Datetime\TimeInterface;
use Drupal\Tests\UnitTestCase;
/**
* Class RedirectDatabaseStorageTest.
* Tests the RedirectDatabaseStorage class.
*
* @coversDefaultClass \Drupal\redirect_extensions\RedirectDatabaseStorage
* @group redirect_extensions
@@ -26,6 +20,7 @@ use Drupal\Tests\UnitTestCase;
class RedirectDatabaseStorageTest extends UnitTestCase {
use ProphecyTrait;
/**
* @covers ::redirectExists
* @dataProvider addDataProvider
@@ -37,15 +32,23 @@ class RedirectDatabaseStorageTest extends UnitTestCase {
$accountProphecy = $this->prophesize(AccountInterface::class);
$timeProphecy = $this->prophesize(TimeInterface::class);
$queryProphecy = $this->prophesize(SelectInterface::class);
$countQueryProphecy = $this->prophesize(SelectInterface::class);
$resultProphecy = $this->prophesize(StatementInterface::class);
$redirect_id = "1";
$resultProphecy->rowCount()->willReturn($count);
$queryProphecy->fields('r')->shouldBeCalledTimes(1);
$queryProphecy->condition('rid', $redirect_id, '=')->shouldBeCalledTimes(1);
$queryProphecy->execute()->willReturn($resultProphecy->reveal());
$queryProphecy->fields('r')->shouldBeCalledTimes(1)
->willReturn($queryProphecy->reveal());
$queryProphecy->condition('rid', $redirect_id, '=')->shouldBeCalledTimes(1)
->willReturn($queryProphecy->reveal());
$queryProphecy->countQuery()->shouldBeCalledTimes(1)
->willReturn($countQueryProphecy->reveal());
$countQueryProphecy->execute()->shouldBeCalledTimes(1)
->willReturn($resultProphecy->reveal());
$resultProphecy->fetchField()->shouldBeCalledTimes(1)
->willReturn($count);
$connectionProphecy->select("redirect_extensions", "r")
->willReturn($queryProphecy->reveal());
@@ -60,7 +63,7 @@ class RedirectDatabaseStorageTest extends UnitTestCase {
/**
* Data provider for test.
*/
public function addDataProvider() {
public static function addDataProvider() {
return [
[0, FALSE],
[1, TRUE],
Loading