diff options
author | wei <> | 2007-01-14 02:10:24 +0000 |
---|---|---|
committer | wei <> | 2007-01-14 02:10:24 +0000 |
commit | 45b0fe42a979d444d547a5248eb2e9e915aaf16a (patch) | |
tree | 2480dae3350e4a70949956c41984cceb8dce3efc /tests/simple_unit | |
parent | 898049a4012eaecd99e7a418726215e656677809 (diff) |
Add "block-content" to allow user comments on block level elements in quickstart docs.
Diffstat (limited to 'tests/simple_unit')
-rw-r--r-- | tests/simple_unit/ActiveRecord/CriteriaTestCase.php | 36 | ||||
-rw-r--r-- | tests/simple_unit/Soap/ContactManager.php | 10 | ||||
-rw-r--r-- | tests/simple_unit/Soap/SoapTestCase.php | 91 | ||||
-rw-r--r-- | tests/simple_unit/application.xml | 9 | ||||
-rw-r--r-- | tests/simple_unit/ws.php | 9 |
5 files changed, 154 insertions, 1 deletions
diff --git a/tests/simple_unit/ActiveRecord/CriteriaTestCase.php b/tests/simple_unit/ActiveRecord/CriteriaTestCase.php new file mode 100644 index 00000000..f1545e1d --- /dev/null +++ b/tests/simple_unit/ActiveRecord/CriteriaTestCase.php @@ -0,0 +1,36 @@ +<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+class CriteriaTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_orderby_only()
+ {
+ $criteria = new TActiveRecordCriteria;
+ $criteria->OrdersBy['name'] = 'asc';
+ $records = DepartmentRecord::finder()->findAll($criteria);
+ $this->assertEqual(count($records), 8);
+ $this->assertEqual($records[0]->name, '+GX Service');
+ $this->assertEqual($records[7]->name, 'Marketing');
+ }
+
+ function test_orderby_only_desc()
+ {
+ $criteria = new TActiveRecordCriteria;
+ $criteria->OrdersBy['name'] = 'desc';
+ $records = DepartmentRecord::finder()->findAll($criteria);
+ $this->assertEqual(count($records), 8);
+ $this->assertEqual($records[7]->name, '+GX Service');
+ $this->assertEqual($records[0]->name, 'Marketing');
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/simple_unit/Soap/ContactManager.php b/tests/simple_unit/Soap/ContactManager.php index e8b12d99..8bf3d756 100644 --- a/tests/simple_unit/Soap/ContactManager.php +++ b/tests/simple_unit/Soap/ContactManager.php @@ -56,7 +56,7 @@ class ContactManager{ * @soapmethod
*/
public function saveContact(Contact $Contact) {
- error_log(var_export($Contact,true));
+ //error_log(var_export($Contact,true));
//$Contact->save();
return true;
}
@@ -70,6 +70,14 @@ class ContactManager{ return array(array(1,2), array("12", 1.2));
}
+ /**
+ * @return array
+ * @soapmethod
+ */
+ public function getEmptyArray()
+ {
+ return array();
+ }
}
diff --git a/tests/simple_unit/Soap/SoapTestCase.php b/tests/simple_unit/Soap/SoapTestCase.php new file mode 100644 index 00000000..78a6875b --- /dev/null +++ b/tests/simple_unit/Soap/SoapTestCase.php @@ -0,0 +1,91 @@ +<?php
+
+ini_set("soap.wsdl_cache_enabled",0);
+
+require_once(dirname(__FILE__).'/ContactManager.php');
+
+class SoapTestCase extends UnitTestCase
+{
+ function getWsdlUri()
+ {
+ $script = str_replace('unit.php', 'ws.php',$_SERVER['SCRIPT_NAME']);
+ return "http://".$_SERVER['HTTP_HOST'].$script.'?soap=contacts.wsdl';
+ }
+
+ function getClient()
+ {
+ return new SoapClient($this->getWsdlUri());
+ }
+
+ function testContactArray()
+ {
+ $result = $this->getClient()->getContacts();
+ $this->assertEqual(count($result), 1);
+ $obj = $result[0];
+ $this->assertEqual($obj->name, "me");
+ $this->assertEqual($obj->id, 1);
+ $this->assertEqual($obj->address->street, "sesamstreet");
+ $this->assertNull($obj->address->nr);
+ $this->assertNull($obj->address->zipcode);
+ $this->assertEqual($obj->address->city, "sesamcity");
+ $this->assertEqual($obj->email, "me@you.com");
+ }
+
+ function testGetContactThrowsException()
+ {
+ try
+ {
+ $result = $this->getClient()->getContact(1);
+ $this->fail();
+ }
+ catch (SoapFault $f)
+ {
+ $this->pass();
+ }
+ }
+
+ function testGetNewContact()
+ {
+ $obj = $this->getClient()->newContact();
+ $this->assertNull($obj->name);
+ $this->assertNull($obj->id);
+ $this->assertNull($obj->address);
+ $this->assertNull($obj->email);
+ }
+
+ function testSaveContactReturnsTrue()
+ {
+ $c = new Contact;
+ $result = $this->getClient()->saveContact($c);
+ $this->assertTrue($result);
+ }
+
+ function getMixedArray()
+ {
+ $result = $this->getClient()>getList();
+ $expected = array(array(1,2), array("12", 1.2));
+ $this->assertEqual($result, $expected);
+ }
+
+ function testEmptyArray()
+ {
+ $result = $this->getClient()->getEmptyArray();
+ $this->assertTrue(is_array($result));
+ $this->assertEqual(count($result), 0);
+ }
+
+ function testUnknownFunctionThrowsException()
+ {
+ try
+ {
+ $this->getClient()->test();
+ $this->fail();
+ }
+ catch (SoapFault $f)
+ {
+ $this->pass();
+ }
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/simple_unit/application.xml b/tests/simple_unit/application.xml new file mode 100644 index 00000000..971d5684 --- /dev/null +++ b/tests/simple_unit/application.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<application id="simple_unit" mode="Debug">
+ <services>
+ <service id="soap" class="System.Web.Services.TSoapService">
+ <soap id="contacts" provider="Application.Soap.ContactManager" ClassMaps="Contact, Address"/>
+ </service>
+ </services>
+</application>
\ No newline at end of file diff --git a/tests/simple_unit/ws.php b/tests/simple_unit/ws.php new file mode 100644 index 00000000..97e21cad --- /dev/null +++ b/tests/simple_unit/ws.php @@ -0,0 +1,9 @@ +<?php
+
+include_once '../../framework/prado.php';
+include_once './Soap/ContactManager.php';
+
+$app = new TApplication('.');
+$app->run();
+
+?>
\ No newline at end of file |