class RouteGroupResolverTest in Organic groups 8
Tests the RouteGroupResolver plugin.
@group og @coversDefaultClass \Drupal\og\Plugin\OgGroupResolver\RouteGroupResolver
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\og\Unit\Plugin\OgGroupResolver\OgGroupResolverTestBase
- class \Drupal\Tests\og\Unit\Plugin\OgGroupResolver\OgRouteGroupResolverTestBase
- class \Drupal\Tests\og\Unit\Plugin\OgGroupResolver\RouteGroupResolverTest
- class \Drupal\Tests\og\Unit\Plugin\OgGroupResolver\OgRouteGroupResolverTestBase
- class \Drupal\Tests\og\Unit\Plugin\OgGroupResolver\OgGroupResolverTestBase
Expanded class hierarchy of RouteGroupResolverTest
File
- tests/
src/ Unit/ Plugin/ OgGroupResolver/ RouteGroupResolverTest.php, line 16
Namespace
Drupal\Tests\og\Unit\Plugin\OgGroupResolverView source
class RouteGroupResolverTest extends OgRouteGroupResolverTestBase {
/**
* {@inheritdoc}
*/
protected $className = RouteGroupResolver::class;
/**
* {@inheritdoc}
*/
protected $pluginId = 'route_group';
/**
* {@inheritdoc}
*/
protected function getInjectedDependencies() {
return [
$this->routeMatch
->reveal(),
$this->groupTypeManager
->reveal(),
$this->entityTypeManager
->reveal(),
];
}
/**
* {@inheritdoc}
*/
protected function getTestEntityProperties() {
return [
'group' => [
'type' => 'node',
'bundle' => 'group',
'group' => TRUE,
],
'group_content' => [
'type' => 'entity_test',
'bundle' => 'group_content',
],
'non_group' => [
'type' => 'taxonomy_term',
'bundle' => 'taxonomy_term',
],
];
}
/**
* Returns a list of test entity types.
*
* This mimicks the data returned by EntityTypeManager::getDefinitions().
*
* @return \Drupal\Core\Entity\EntityTypeInterface[]
* A list of mocked entity types.
*
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions()
*/
protected function getEntityTypes() {
return [
'node' => $this
->prophesize(ContentEntityInterface::class),
];
}
/**
* Data provider for testResolve().
*
* @see ::testResolve()
*/
public function resolveProvider() {
return [
// Test that no groups are returned on a path that is not associated with
// any entities.
[
// A path that is not associated with any entities.
'/user/logout',
// There is no entity on this route.
NULL,
// So the plugin should not find anything.
[],
],
// Test that if we are on the canonical entity page of a group, the
// correct group is returned.
[
// We're on the canonical group entity page.
'/node/{node}',
// The test group is found on the route.
'group',
// The plugin should be able to figure out this is a group.
[
'group',
],
],
// Test that if we are on the delete form of a group, the correct group is
// returned.
[
'/node/{node}/delete',
'group',
[
'group',
],
],
// Test that if we are on the canonical entity page of a group content
// entity, no group should be returned.
[
'/entity_test/{entity_test}',
'group_content',
[],
],
// Test that if we are on the delete form of a group content entity, no
// group should be returned.
[
'/entity_test/delete/entity_test/{entity_test}',
'group_content',
[],
],
// Test that if we are on the canonical entity page of an entity that is
// neither a group nor group content, no group should be returned.
[
'/taxonomy/term/{taxonomy_term}',
'non_group',
[],
],
// Test that if we are on the delete form of an entity that is neither a
// group nor group content, no group should be returned.
[
'/taxonomy/term/{taxonomy_term}/delete',
'non_group',
[],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OgGroupResolverTestBase:: |
protected | property | The mocked entity type manager. | |
OgGroupResolverTestBase:: |
protected | property | The OG group audience helper. | |
OgGroupResolverTestBase:: |
protected | property | The mocked OG group type manager. | |
OgGroupResolverTestBase:: |
protected | property | The OG membership manager. | |
OgGroupResolverTestBase:: |
protected | property | Mocked test entities. | |
OgGroupResolverTestBase:: |
protected | function | Creates a mocked content entity to use in the test. | 1 |
OgGroupResolverTestBase:: |
protected | function | Returns an instance of the plugin under test. | |
OgGroupResolverTestBase:: |
public | function | Tests if the plugin is able to stop the group resolving process. | |
OgRouteGroupResolverTestBase:: |
protected | property | A list of link templates that belong to entity types used in the tests. | |
OgRouteGroupResolverTestBase:: |
protected | property | The mocked route matcher. | |
OgRouteGroupResolverTestBase:: |
protected | function | Returns a set of entity link templates for testing. | |
OgRouteGroupResolverTestBase:: |
protected | function | Adds an expectation that checks if the route object is a group. | |
OgRouteGroupResolverTestBase:: |
protected | function | Adds an expectation that the plugin will (not) retrieve the route object. | |
OgRouteGroupResolverTestBase:: |
protected | function |
Overrides OgGroupResolverTestBase:: |
|
OgRouteGroupResolverTestBase:: |
public | function |
@todo Update documentation. Overrides OgGroupResolverTestBase:: |
|
OgRouteGroupResolverTestBase:: |
protected | function | Adds an expectation that the plugin will retrieve a list of entity paths. | |
OgRouteGroupResolverTestBase:: |
protected | function | Adds an expectation that the current path will be retrieved from the route. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RouteGroupResolverTest:: |
protected | property |
The fully qualified class name of the plugin under test. Overrides OgGroupResolverTestBase:: |
|
RouteGroupResolverTest:: |
protected | property |
The ID of the plugin under test. Overrides OgGroupResolverTestBase:: |
|
RouteGroupResolverTest:: |
protected | function | Returns a list of test entity types. | |
RouteGroupResolverTest:: |
protected | function |
Returns the mocked classes that the plugin depends on. Overrides OgGroupResolverTestBase:: |
|
RouteGroupResolverTest:: |
protected | function |
Returns properties used to create mock test entities. Overrides OgGroupResolverTestBase:: |
|
RouteGroupResolverTest:: |
public | function | Data provider for testResolve(). | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |