How to test an extension: got "Unauthorized" when using m as parameter
When i use the m (= model IRI) as a controller-action-parameter, i got an Unauthorized as response text, no matter what. Do i have to authenticate me before using m? A workaround could be using modelIri, or something else, but it does not make any sense.
(I am using make test-extensions)
class CubeVizControllerTest extends OntoWiki_Test_ControllerTestCase
{
public function setUp ()
{
$this->_extensionName = 'cubeviz';
$this->setUpExtensionUnitTest();
}
/**
* @test
*/
public function getdatasetsAction_parameterMAndDsdUrlSet()
{
$this->request
->setPost(array('m' => $exampleCubeUri, 'dsdUrl' => ""));
/**
* test area
*/
// do something...
$this->dispatch('/cubeviz/getdatasets');
// check output ...
}
}
The m parameter is a special parameter that is handled by a controller plugin automatically. This param will lead to a SPARQL query and thus a triple store is needed. You have two options:
- Use another parameter
- Make your test an integration test not a unit tests. Integration tests have access to the triple store, unit tests do not have access
I used modelIri instead of m, it works. If there is no model with the given model IRI i get Unauthorized as well, but anyway, thats not the problem here :)
Integration tests have access to the triple store, unit tests do not have access
Could you please explain why?