Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add test

  • Loading branch information...
commit c180918871ffe2bca8344647bbcf721b8dcf53be 1 parent 74725cf
Takashi Nojima authored October 15, 2011
65  tests/cases/datasources/rest_source.test.php
... ...
@@ -0,0 +1,65 @@
  1
+<?php
  2
+
  3
+App::import('Model', 'AppModel');
  4
+
  5
+class RestTestModel extends AppModel {
  6
+
  7
+    public $name = 'RestTestModel';
  8
+    public $useDbConfig = 'rest_test';
  9
+    public $request = array();
  10
+
  11
+}
  12
+
  13
+/**
  14
+ * @property RestTestModel $Model
  15
+ */
  16
+class RestSourceTestCase extends CakeTestCase {
  17
+
  18
+    public function startCase() {
  19
+        ConnectionManager::create('rest_test', array(
  20
+            'datasource' => 'Rest.RestSource',
  21
+            'database' => false,
  22
+        ));
  23
+    }
  24
+
  25
+    public function startTest($method) {
  26
+
  27
+        $this->Model = ClassRegistry::init('RestTestModel');
  28
+    }
  29
+
  30
+    public function endTest($method) {
  31
+        unset($this->Model);
  32
+        ClassRegistry::flush();
  33
+    }
  34
+
  35
+    // =========================================================================
  36
+    public function testRead_json() {
  37
+
  38
+        $this->Model->request = array(
  39
+            'uri' => array(
  40
+                'host' => 'search.twitter.com',
  41
+                'path' => 'search.json',
  42
+                'query' => array('q' => 'twitter'),
  43
+            ),
  44
+        );
  45
+
  46
+        $results = $this->Model->find('all');
  47
+
  48
+        $this->assertTrue(isset($results['results']));
  49
+    }
  50
+
  51
+    public function testRead_xml() {
  52
+
  53
+        $this->Model->request = array(
  54
+            'uri' => array(
  55
+                'host' => 'bakery.cakephp.org',
  56
+                'path' => 'articles.rss',
  57
+            ),
  58
+        );
  59
+
  60
+        $results = $this->Model->find('all');
  61
+
  62
+        $this->assertTrue(isset($results['rss']));
  63
+    }
  64
+
  65
+}

0 notes on commit c180918

Please sign in to comment.
Something went wrong with that request. Please try again.