Last change
on this file since 298 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
1.4 KB
|
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | require_once('def/resource.php'); |
---|
4 | |
---|
5 | /** |
---|
6 | * @namespace Tonic\Tests |
---|
7 | */ |
---|
8 | class ResourceTester extends UnitTestCase { |
---|
9 | |
---|
10 | function testFunctioningResourceExec() { |
---|
11 | |
---|
12 | $config = array( |
---|
13 | 'uri' => '/resourcetest/one' |
---|
14 | ); |
---|
15 | |
---|
16 | $request = new Request($config); |
---|
17 | $resource = $request->loadResource(); |
---|
18 | $response = $resource->exec($request); |
---|
19 | |
---|
20 | $this->assertEqual($response->code, '200'); |
---|
21 | $this->assertEqual($response->body, 'test'); |
---|
22 | |
---|
23 | } |
---|
24 | |
---|
25 | function testNoParametersArgumentToResourceConstructor() { |
---|
26 | |
---|
27 | $config = array( |
---|
28 | 'uri' => '/resourcetest/badconstructor' |
---|
29 | ); |
---|
30 | |
---|
31 | $this->expectError(new PatternExpectation('/Missing argument 1 for Resource::__construct/')); |
---|
32 | $this->expectError(new PatternExpectation('/Undefined variable: parameters/')); |
---|
33 | |
---|
34 | $request = new Request($config); |
---|
35 | $resource = $request->loadResource(); |
---|
36 | |
---|
37 | } |
---|
38 | |
---|
39 | function testMethodDoesNotReturnResponseObject() { |
---|
40 | |
---|
41 | $config = array( |
---|
42 | 'uri' => '/resourcetest/badmethodresponse' |
---|
43 | ); |
---|
44 | |
---|
45 | $this->expectException(new PatternExpectation('/Method GET of (.+\\\\)?TestBadMethodResponse did not return a Response object/')); |
---|
46 | |
---|
47 | $request = new Request($config); |
---|
48 | $resource = $request->loadResource(); |
---|
49 | $response = $resource->exec($request); |
---|
50 | |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
Note: See
TracBrowser
for help on using the repository browser.