summaryrefslogtreecommitdiff
path: root/tests/unit/Soap/ContactManager.php
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2016-03-25 17:55:51 +0100
committerFabio Bas <ctrlaltca@gmail.com>2016-03-25 17:55:51 +0100
commita3388622287e218beddfa14a47ed677d4307b36b (patch)
tree1b4c7ac8597b1cc798b6683d4a81c90d38de12f6 /tests/unit/Soap/ContactManager.php
parentc7fd3e1167b6f2fa7746edbd0fb8f8c1694c61f9 (diff)
Removed simpletest and moved all tests in the unit tree
Tests are executed now, but a lot of them need fixing.
Diffstat (limited to 'tests/unit/Soap/ContactManager.php')
-rw-r--r--tests/unit/Soap/ContactManager.php155
1 files changed, 155 insertions, 0 deletions
diff --git a/tests/unit/Soap/ContactManager.php b/tests/unit/Soap/ContactManager.php
new file mode 100644
index 00000000..2fbeec48
--- /dev/null
+++ b/tests/unit/Soap/ContactManager.php
@@ -0,0 +1,155 @@
+<?php
+
+/**
+ * Keeps track of the people in our Contact list.
+ *
+ * Starts with a standard Contact list and can add
+ * new people to our list or change existing Contacts.
+ * This class is for example purposes only, just to
+ * show how to create a webservice
+ */
+class ContactManager{
+
+ /**
+ * Gets the current Contact list.
+ * @return Contact[]
+ * @soapmethod
+ */
+ public function getContacts() {
+ $Contact = new Contact();
+ $Contact->address = new Address();
+ $Contact->address->city ="sesamcity";
+ $Contact->address->street ="sesamstreet";
+ $Contact->email = "me@you.com";
+ $Contact->id = 1;
+ $Contact->name ="me";
+
+ $ret[] = $Contact;
+ //debugObject("Contacten: ",$ret);
+ return $ret;
+ }
+
+ /**
+ * Gets the Contact with the given id.
+ * @param int $id The id
+ * @return Contact
+ * @soapmethod
+ */
+ public function getContact($id) {
+ //get Contact from db
+ //might wanna throw an exception when it does not exists
+ throw new Exception("Contact '$id' not found");
+ }
+ /**
+ * Generates an new, empty Contact template
+ * @return Contact
+ * @soapmethod
+ */
+ public function newContact() {
+ return new Contact();
+ }
+
+ /**
+ * Saves a given Contact
+ * @param Contact $Contact
+ * @return boolean
+ * @soapmethod
+ */
+ public function saveContact(Contact $Contact) {
+ //error_log(var_export($Contact,true));
+ //$Contact->save();
+ return true;
+ }
+
+ /**
+ * @return mixed
+ * @soapmethod
+ */
+ public function getList()
+ {
+ return array(array(1,2), array("12", 1.2));
+ }
+
+ /**
+ * @return array
+ * @soapmethod
+ */
+ public function getEmptyArray()
+ {
+ return array();
+ }
+
+}
+
+
+/**
+ * The Contact details for a person
+ *
+ * Stores the person's name, address and e-mail
+ * This class is for example purposes only, just to
+ * show how to create a webservice
+ *
+ */
+class Contact{
+
+ /**
+ * @var int $id
+ * @soapproperty
+ */
+ public $id;
+
+ /**
+ * @var string $name
+ * @soapproperty
+ */
+ public $name;
+
+ /** @var Address $address
+ * @soapproperty
+ */
+ public $address;
+
+ /** @var string $email
+ * @soapproperty
+ */
+ public $email;
+
+ /**
+ * saves a Contact
+ *
+ * @return void
+ */
+ public function save() {
+ //save Contact 2 db
+ }
+}
+
+/**
+ * Stores an address
+ *
+ * An address consists of a street, number, zipcode and city.
+ * This class is for example purposes only, just to
+ * show how to create a webservice
+ *
+ */
+class Address{
+ /** @var string $street
+ * @soapproperty
+ */
+ public $street;
+
+ /** @var string $nr
+ * @soapproperty
+ */
+ public $nr;
+
+ /** @var string $zipcode
+ * @soapproperty
+ */
+ public $zipcode;
+
+ /** @var string $city
+ * @soapproperty
+ */
+ public $city;
+}