OntoWiki icon indicating copy to clipboard operation
OntoWiki copied to clipboard

How to test an extension: got "Unauthorized" when using m as parameter

Open k00ni opened this issue 12 years ago • 2 comments

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 ...
    }
}

k00ni avatar Mar 01 '13 14:03 k00ni

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:

  1. Use another parameter
  2. Make your test an integration test not a unit tests. Integration tests have access to the triple store, unit tests do not have access

pfrischmuth avatar Mar 04 '13 08:03 pfrischmuth

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?

k00ni avatar Mar 04 '13 12:03 k00ni