Comments (12)
It seems you are right. But I don't know why codeigniter-restserver does not use CI_Input::get()
.
from ci-phpunit-test.
How about this?
$output = $this->request('GET', 'query_string/index/name/Mike');
from ci-phpunit-test.
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.
have you any suggestion how I inject the above url to the codigniter?
from ci-phpunit-test.
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.
I posted issue to ask why.
chriskacerguis/codeigniter-restserver#544
from ci-phpunit-test.
Thanks.
I made a quick test for workaround you wrote above and is look like ok.
from ci-phpunit-test.
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.
Thanks, I will try ASAP
from ci-phpunit-test.
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.
@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.
Thanks
from ci-phpunit-test.
Related Issues (20)
- 3.0.2 release date? HOT 2
- Coverage report is acting weird HOT 2
- Cannot create mock whose methods throw exceptions HOT 2
- How to extend the test runner for post operations? HOT 4
- 3.x new version with Updates for PHP 8.1 HOT 3
- How to stop PHP code execution when exit() in unit test? HOT 5
- Argument 1 passed to PHPUnit\Runner\TestSuiteSorter::reorderTestsInSuite() must implement interface PHPUnit\Framework\Test, instance of PHPUnit\Framework\TestSuite given HOT 3
- PHPUnit 9.5.24 + CodeIgniter 3.1.13 + PHP 8.1 HOT 2
- Session problem HOT 8
- Mocking DB object can't use getDouble? HOT 1
- How to clear RAM memory after run testcase in testsuite? HOT 3
- How to mock DB in CI? HOT 1
- PHP Fatal error: Uncaught Error: Class "TestCase" not found HOT 2
- Replacement of helper function redirect() does not work HOT 3
- cant set session $this->session->userdata HOT 1
- Upgrading to CodeIgniter4 is strongly recommended
- How to test external API with json response? HOT 1
- 1.0.2 fails with phpunit <7 when installed with "--from-composer" HOT 2
- issue during code coverage when referencing $this->uri in a view HOT 5
- Add support for php 8.2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ci-phpunit-test.