public function testLifecycleSupplier() { $retVal = $this->_createSupplier(); $this->assertEquals(4294967, $retVal["number"]); $this->assertEquals("Worldwide Electronics International", $retVal["name"]); $this->assertEquals("http://wwei.cn", $retVal["url"]); $this->assertEquals(NULL, $retVal['description']); $this->assertEquals('Yiting', $retVal['cpextern_id']['n_given']); $this->assertEquals('Huang', $retVal['cpextern_id']['n_family']); $this->assertEquals('Hans Friedrich', $retVal['cpintern_id']['n_given']); $this->assertEquals('Ochs', $retVal['cpintern_id']['n_family']); // delete record (set deleted=1) of customer and assigned addresses $this->_json->deleteSuppliers(array($retVal['id'])); $customerBackend = new Sales_Backend_Supplier(); $deletedSupplier = $customerBackend->get($retVal['id'], TRUE); $this->assertEquals(1, $deletedSupplier->is_deleted); $addressBackend = new Sales_Backend_Address(); $deletedAddresses = $addressBackend->getMultipleByProperty($retVal['id'], 'customer_id', TRUE); $this->assertEquals(1, $deletedAddresses->count()); foreach ($deletedAddresses as $address) { $this->assertEquals(1, $address->is_deleted); } $this->setExpectedException('Tinebase_Exception_NotFound'); return $this->_json->getSupplier($retVal['id']); }
public function testLifecycleCustomer() { $retVal = $this->_createCustomer(); $this->assertEquals(4294967, $retVal["number"]); $this->assertEquals("Worldwide Electronics International", $retVal["name"]); $this->assertEquals("http://wwei.cn", $retVal["url"]); $this->assertEquals(NULL, $retVal['description']); $this->assertEquals('Yiting', $retVal['cpextern_id']['n_given']); $this->assertEquals('Huang', $retVal['cpextern_id']['n_family']); $this->assertEquals('Hans Friedrich', $retVal['cpintern_id']['n_given']); $this->assertEquals('Ochs', $retVal['cpintern_id']['n_family']); // @see: 0009378: create a test for resolving dependent records recursively $this->assertEquals('Sales_Model_Contract', $retVal['billing'][0]['relations'][0]['related_model']); $this->assertEquals('Testing', $retVal['billing'][0]['relations'][0]['related_record']['title']); $this->assertArrayHasKey('fulltext', $retVal['billing'][0]); // @see: 0009378: create a test for resolving dependent records recursively $this->assertEquals('Sales_Model_Contract', $retVal['billing'][0]['relations'][0]['related_model']); $this->assertEquals('Testing', $retVal['billing'][0]['relations'][0]['related_record']['title']); // test billing and delivery addresses get resolved $this->assertTrue(is_array($retVal['delivery'])); $this->assertEquals(1, count($retVal['delivery'])); $this->assertEquals('Peking', $retVal['delivery'][0]['locality']); $this->assertEquals('China', $retVal['delivery'][0]['countryname']); $this->assertTrue(is_array($retVal['billing'])); $this->assertEquals(1, count($retVal['billing'])); $this->assertEquals('Shenzen', $retVal['billing'][0]['locality']); $this->assertEquals('China', $retVal['billing'][0]['countryname']); // delete record (set deleted=1) of customer and assigned addresses $this->_json->deleteCustomers(array($retVal['id'])); $customerBackend = new Sales_Backend_Customer(); $deletedCustomer = $customerBackend->get($retVal['id'], TRUE); $this->assertEquals(1, $deletedCustomer->is_deleted); $addressBackend = new Sales_Backend_Address(); $deletedAddresses = $addressBackend->getMultipleByProperty($retVal['id'], 'customer_id', TRUE); $this->assertEquals(3, $deletedAddresses->count()); foreach ($deletedAddresses as $address) { $this->assertEquals(1, $address->is_deleted); } $this->setExpectedException('Tinebase_Exception_NotFound'); return $this->_json->getCustomer($retVal['id']); }