class ServiceResourceTest in Services 8.4
Same name and namespace in other branches
- 9.0.x tests/src/Unit/Entity/ServiceResourceTest.php \Drupal\Tests\services\Unit\Entity\ServiceResourceTest
@coversDefaultClass \Drupal\services\Entity\ServiceResource
@group services
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\services\Unit\Entity\ServiceResourceTest
Expanded class hierarchy of ServiceResourceTest
File
- tests/
src/ Unit/ Entity/ ServiceResourceTest.php, line 13
Namespace
Drupal\Tests\services\Unit\EntityView source
class ServiceResourceTest extends UnitTestCase {
public function testCanConstructDefaultResource() {
/** @var \Drupal\services\Entity\ServiceResource $resource */
$resource = new ServiceResource([
'service_plugin_id' => 'test:plugin:id',
'service_endpoint_id' => 'test_endpoint_id',
'formats' => [
'json',
],
'authentication' => [
'cookie',
],
'no_cache' => 0,
], 'service_endpoint_resource');
$this
->assertEquals('test_endpoint_id.test.plugin.id', $resource
->id(), 'ID constructed successfully.');
$this
->assertEquals([
'json',
], $resource
->getFormats(), 'Formats found.');
$this
->assertEquals([
'cookie',
], $resource
->getAuthentication(), 'Authentication found.');
$this
->assertEquals(0, $resource
->getNoCache(), 'Cache setting found.');
}
public function testCanConstructResourceNoCacheFalse() {
/** @var \Drupal\services\Entity\ServiceResource $resource */
$resource = new ServiceResource([
'service_plugin_id' => 'test:plugin:id',
'service_endpoint_id' => 'test_endpoint_id',
'formats' => [],
'authentication' => [],
'no_cache' => FALSE,
], 'service_endpoint_resource');
$this
->assertEquals(0, $resource
->getNoCache(), 'Cache setting found.');
}
public function testCanConstructResourceNoCacheTrue() {
/** @var \Drupal\services\Entity\ServiceResource $resource */
$resource = new ServiceResource([
'service_plugin_id' => 'test:plugin:id',
'service_endpoint_id' => 'test_endpoint_id',
'formats' => [],
'authentication' => [],
'no_cache' => TRUE,
], 'service_endpoint_resource');
$this
->assertEquals(1, $resource
->getNoCache(), 'Cache setting found.');
}
public function testCanConstructResourceNoCache1() {
/** @var \Drupal\services\Entity\ServiceResource $resource */
$resource = new ServiceResource([
'service_plugin_id' => 'test:plugin:id',
'service_endpoint_id' => 'test_endpoint_id',
'formats' => [],
'authentication' => [],
'no_cache' => 1,
], 'service_endpoint_resource');
$this
->assertEquals(1, $resource
->getNoCache(), 'Cache setting found.');
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
ServiceResourceTest:: |
public | function | ||
ServiceResourceTest:: |
public | function | ||
ServiceResourceTest:: |
public | function | ||
ServiceResourceTest:: |
public | function | ||
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. | |
UnitTestCase:: |
protected | function | 340 |