/** * checks if all properties are resolved and saved properly */ public function testCRUD() { $this->_createCustomers(); $this->_createContracts(); $json = new Sales_Frontend_Json(); $customer = $json->getCustomer($this->_customerRecords->filter('name', 'Customer3')->getFirstRecord()->getId()); $this->assertTrue(is_array($customer['postal_id'])); $this->assertEquals($customer['adr_id'], $customer['postal_id']['id']); $this->assertTrue(is_array($customer['billing'])); $this->assertEquals(1, count($customer['billing'])); $this->assertTrue(is_array($customer['delivery'])); $this->assertEquals(1, count($customer['delivery'])); $this->assertTrue(is_array($customer['relations'])); $this->assertTrue(is_array($customer['relations'][0]['related_record'])); $this->assertEquals(1, count($customer['relations'])); $this->assertEquals('CUSTOMER', $customer['relations'][0]['type']); $customer['billing'][1] = array('prefix1' => 'Dr.', 'prefix2' => 'George Harbottle', 'street' => 'Glasgow Str. 432', 'postalcode' => '532 45', 'locality' => 'Birmingham', 'type' => 'billing'); $customer['delivery'][1] = array('prefix1' => 'Mr.', 'prefix2' => 'Peter Harbottle', 'street' => 'London Str. 123', 'postalcode' => '532 23', 'locality' => 'Birmingham', 'type' => 'delivery'); $customer = $json->saveCustomer($customer); $this->assertEquals(2, count($customer['billing'])); $this->assertEquals(2, count($customer['delivery'])); // remove contracts, otherwise deleting customers having an contract-assigned billing address would fail $this->_contractController->delete($this->_contractRecords->getId()); $json->deleteCustomers(array($customer['id'])); $this->setExpectedException('Tinebase_Exception_NotFound'); $json->getCustomer($customer['id']); }
/** * testCustomerConcurrencyManagement */ public function testCustomerConcurrencyManagement() { $customer = $this->_instance->saveCustomer(array('name' => Tinebase_Record_Abstract::generateUID())); $customer['adr_type'] = 'postal'; $customer['adr_prefix1'] = 'test'; $customer = $this->_instance->saveCustomer($customer); $customer['adr_prefix1'] = 'test test'; // js client does not send adr_seq unset($customer['adr_seq']); $updatedCustomer = $this->_instance->saveCustomer($customer); $this->assertEquals('test test', $updatedCustomer['postal_id']['prefix1']); $this->assertEquals(3, $updatedCustomer['postal_id']['seq']); $this->assertEquals(3, $updatedCustomer['adr_seq']); }