Permalink
Browse files

add test

  • Loading branch information...
1 parent 74725cf commit c180918871ffe2bca8344647bbcf721b8dcf53be @nojimage nojimage committed Oct 15, 2011
Showing with 65 additions and 0 deletions.
  1. +65 −0 tests/cases/datasources/rest_source.test.php
@@ -0,0 +1,65 @@
+<?php
+
+App::import('Model', 'AppModel');
+
+class RestTestModel extends AppModel {
+
+ public $name = 'RestTestModel';
+ public $useDbConfig = 'rest_test';
+ public $request = array();
+
+}
+
+/**
+ * @property RestTestModel $Model
+ */
+class RestSourceTestCase extends CakeTestCase {
+
+ public function startCase() {
+ ConnectionManager::create('rest_test', array(
+ 'datasource' => 'Rest.RestSource',
+ 'database' => false,
+ ));
+ }
+
+ public function startTest($method) {
+
+ $this->Model = ClassRegistry::init('RestTestModel');
+ }
+
+ public function endTest($method) {
+ unset($this->Model);
+ ClassRegistry::flush();
+ }
+
+ // =========================================================================
+ public function testRead_json() {
+
+ $this->Model->request = array(
+ 'uri' => array(
+ 'host' => 'search.twitter.com',
+ 'path' => 'search.json',
+ 'query' => array('q' => 'twitter'),
+ ),
+ );
+
+ $results = $this->Model->find('all');
+
+ $this->assertTrue(isset($results['results']));
+ }
+
+ public function testRead_xml() {
+
+ $this->Model->request = array(
+ 'uri' => array(
+ 'host' => 'bakery.cakephp.org',
+ 'path' => 'articles.rss',
+ ),
+ );
+
+ $results = $this->Model->find('all');
+
+ $this->assertTrue(isset($results['rss']));
+ }
+
+}

0 comments on commit c180918

Please sign in to comment.