Skip to content

Commit

Permalink
Add tests for ResourceManager::getResourceIdFromRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainweb committed Aug 26, 2016
1 parent 9070bad commit ba9ba8d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/RestfulHookMenuTestCase.test
Expand Up @@ -139,26 +139,31 @@ class RestfulHookMenuTestCase extends RestfulCurlBaseTestCase {
'path' => 'api/v1.1/articles',
'version_header' => NULL,
'expected_version' => array(1, 1),
'expected_resource' => 'articles',
),
array(
'path' => 'api/v1/articles',
'version_header' => NULL,
'expected_version' => array(1, 7),
'expected_resource' => 'articles',
),
array(
'path' => 'api/articles',
'version_header' => 'v1',
'expected_version' => array(1, 7),
'expected_resource' => 'articles',
),
array(
'path' => 'api/articles',
'version_header' => 'v1.0',
'expected_version' => array(1, 0),
'expected_resource' => 'articles',
),
array(
'path' => 'api/articles',
'version_header' => NULL,
'expected_version' => array(2, 1),
'expected_resource' => 'articles',
),
);

Expand All @@ -173,6 +178,7 @@ class RestfulHookMenuTestCase extends RestfulCurlBaseTestCase {
$resource_manager = new \Drupal\restful\Resource\ResourceManager($request);
drupal_static_reset('Drupal\restful\Resource\ResourceManager::getVersionFromRequest');
$this->assertEqual($resource_manager->getVersionFromRequest(), $test_item['expected_version'], sprintf('%s resolves correctly.', $test_item['path']));
$this->assertEqual($resource_manager->getResourceIdFromRequest(), $test_item['expected_resource'], sprintf('Resource name obtained correctly from %s.', $test_item['path']));
}

}
Expand Down

0 comments on commit ba9ba8d

Please sign in to comment.