use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
+use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\entity_test\EntityTestListBuilder;
use Drupal\Tests\UnitTestCase;
*/
protected $role;
+ /**
+ * The redirect destination service.
+ *
+ * @var \Drupal\Core\Routing\RedirectDestinationInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $redirectDestination;
+
/**
* The EntityListBuilder object to test.
*
$this->moduleHandler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface');
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->translationManager = $this->getMock('\Drupal\Core\StringTranslation\TranslationInterface');
- $this->entityListBuilder = new TestEntityListBuilder($this->entityType, $this->roleStorage, $this->moduleHandler);
+ $this->entityListBuilder = new TestEntityListBuilder($this->entityType, $this->roleStorage);
+ $this->redirectDestination = $this->getMock(RedirectDestinationInterface::class);
$this->container = new ContainerBuilder();
\Drupal::setContainer($this->container);
}
$url = $this->getMockBuilder('\Drupal\Core\Url')
->disableOriginalConstructor()
->getMock();
- $url->expects($this->any())
- ->method('toArray')
- ->will($this->returnValue([]));
+ $url->expects($this->atLeastOnce())
+ ->method('mergeOptions')
+ ->with(['query' => ['destination' => '/foo/bar']]);
$this->role->expects($this->any())
- ->method('urlInfo')
+ ->method('toUrl')
->will($this->returnValue($url));
- $list = new EntityListBuilder($this->entityType, $this->roleStorage, $this->moduleHandler);
+ $this->redirectDestination->expects($this->atLeastOnce())
+ ->method('getAsArray')
+ ->willReturn(['destination' => '/foo/bar']);
+
+ $list = new EntityListBuilder($this->entityType, $this->roleStorage);
$list->setStringTranslation($this->translationManager);
+ $list->setRedirectDestination($this->redirectDestination);
$operations = $list->getOperations($this->role);
$this->assertInternalType('array', $operations);