Git Product home page Git Product logo

Comments (12)

kenjis avatar kenjis commented on May 24, 2024

It seems you are right. But I don't know why codeigniter-restserver does not use CI_Input::get().

from ci-phpunit-test.

kenjis avatar kenjis commented on May 24, 2024

How about this?

$output = $this->request('GET', 'query_string/index/name/Mike');

from ci-phpunit-test.

serazoli avatar serazoli commented on May 24, 2024

I have a little bit complicated parameters.
From client side I will get similar GET parameters

"page":"1","rows":"10",'filterRules':[{"field":"time","op":"between","value":["2015-08-01","2015-08-31"]}]

What will be from this parameter in the form proposed by you?
If I use "?" and "&" sign will be this

log?page=1&rows=10&filterRules=%5B%7B%22field%22%3A%22time%22%2C%22op%22%3A%22between%22%2C%22value%22%3A%5B%222015-08-01%22%2C%222015-08-31%22%5D%7D%5D

Thanks

from ci-phpunit-test.

serazoli avatar serazoli commented on May 24, 2024

have you any suggestion how I inject the above url to the codigniter?

from ci-phpunit-test.

kenjis avatar kenjis commented on May 24, 2024

This is workaround for example 7 (User #1 - get it in XML (users/id/1?format=xml)):

        set_is_cli(FALSE);
        $this->warningOff();
        $_SERVER['REQUEST_URI'] = 'api/example/users/id/1?format=xml';
        $output = $this->request('GET', 'api/example/users/id/1');
        set_is_cli(TRUE);
        $this->warningOn();

        $this->assertEquals(
            '<?xml version="1.0" encoding="utf-8"?>
<xml><id>1</id><name>John</name><email>[email protected]</email><fact>Loves coding</fact></xml>
',
            $output
        );
        $this->assertResponseCode(200);

In your case, you set $_SERVER['REQUEST_URI'] like this:

$_SERVER['REQUEST_URI'] = 'log?page=1&rows=10&filterRules=%5B%7B%22field%22%3A%22time%22%2C%22op%22%3A%22between%22%2C%22value%22%3A%5B%222015-08-01%22%2C%222015-08-31%22%5D%7D%5D';

from ci-phpunit-test.

kenjis avatar kenjis commented on May 24, 2024

I posted issue to ask why.
chriskacerguis/codeigniter-restserver#544

from ci-phpunit-test.

serazoli avatar serazoli commented on May 24, 2024

Thanks.
I made a quick test for workaround you wrote above and is look like ok.

from ci-phpunit-test.

kenjis avatar kenjis commented on May 24, 2024

I sent PR: #51

With this PR, we can write test like this:

        set_is_cli(FALSE);
        $this->warningOff();
        $output = $this->request(
            'GET',
            'api/example/users/id/1?format=xml'
        );
        set_is_cli(TRUE);
        $this->warningOn();

        $this->assertEquals(
            '<?xml version="1.0" encoding="utf-8"?>
<xml><id>1</id><name>John</name><email>[email protected]</email><fact>Loves coding</fact></xml>
',
            $output
        );
        $this->assertResponseCode(200);

But we can't remove below, because of implementation of codeigniter-restserver.

        set_is_cli(FALSE);
        $this->warningOff();

from ci-phpunit-test.

serazoli avatar serazoli commented on May 24, 2024

Thanks, I will try ASAP

from ci-phpunit-test.

kenjis avatar kenjis commented on May 24, 2024

If you use latest master of ci-phpunit-test, and this MY_Session class https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/master/application/libraries/Session/MY_Session.php ,

You can write tests without $this->warningOff():
https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/master/application/tests/controllers/api/Example_test.php#L49

from ci-phpunit-test.

kenjis avatar kenjis commented on May 24, 2024

@serazoli
The latest reset server (see master brach) is fixed. And I added a test you want:
kenjis/ci-app-for-ci-phpunit-test@308a47b

from ci-phpunit-test.

serazoli avatar serazoli commented on May 24, 2024

Thanks

from ci-phpunit-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.