public function test_accounts_manage() { // Create user $account = new pybilling\Account(array('name' => 'Dmitry')); $account->save(); # Create $personal_data = new pybilling\PersonalData(array('fio' => "Zbignev Bj Жезинский", 'birth' => '1983-09-05', 'postal_index' => 610001, 'postal_address' => 'Address Postal', 'phone' => '+7 495 6680903', 'passport' => '8734 238764234 239874', 'email' => '*****@*****.**', 'account' => $account->id, 'type' => 'PersonalDataPerson')); $personal_data->save(); $this->assertEquals('610001', $personal_data->postal_index); $this->assertEquals('Zbignev Bj Zhezinskij', $personal_data->fio_lat); $this->assertEquals('Zbignev Bj Жезинский', $personal_data->fio); $this->assertEquals('PersonalDataPerson', $personal_data->type); $this->assertEquals('+7 495 6680903', $personal_data->phone); $this->assertEquals($account->id, $personal_data->account); # Update $personal_data->fio = 'Дмитрий Шиляев'; $personal_data->save(); $personal_data_upd = pybilling\PersonalData::get($personal_data->id); $this->assertEquals($personal_data->id, $personal_data_upd->id); $this->assertEquals('Zbignev Bj Zhezinskij', $personal_data_upd->fio_lat); $this->assertEquals('Дмитрий Шиляев', $personal_data_upd->fio); $this->assertEquals('PersonalDataPerson', $personal_data_upd->type); $this->assertEquals('+7 495 6680903', $personal_data_upd->phone); $this->assertEquals($account->id, $personal_data_upd->account); // Delete $personal_data_upd->delete(); try { pybilling\PersonalData::get($personal_data_upd->id); $this->fail("Waiting for the exception."); } catch (Exception $ex) { $this->assertEquals(404, $ex->getCode()); } }
public function test_accounts_with_contacts_and_personal_data() { $account = new pybilling\Account(array('name' => 'Dmitry')); $account->save(); # Create $personal_data = new pybilling\PersonalData(array('fio' => "Zbignev Bj Жезинский", 'birth' => '1983-09-05', 'postal_index' => 610001, 'postal_address' => 'Address Postal', 'phone' => '+7 495 6680903', 'passport' => '8734 238764234 239874', 'email' => '*****@*****.**', 'account' => $account->id, 'type' => 'PersonalDataPerson')); $personal_data->save(); $aContact = new pybilling\AccountContact(array('name' => 'home', 'address' => '*****@*****.**', 'type' => 'email', 'account' => $account->id)); $aContact->save(); // Checks $updated_account = pybilling\Account::get($account->id); $this->assertEquals(1, count($updated_account->contacts)); $this->assertEquals(1, count($updated_account->personal_data)); // check contacts $contact = $updated_account->contacts[0]; $this->assertEquals('home', $contact->name); $this->assertEquals('email', $contact->type); $this->assertEquals('*****@*****.**', $contact->address); $this->assertEquals($account->id, $contact->account); // check personal data $pdata = $updated_account->personal_data[0]; $this->assertEquals('610001', $pdata->postal_index); $this->assertEquals('Zbignev Bj Zhezinskij', $pdata->fio_lat); $this->assertEquals('Zbignev Bj Жезинский', $pdata->fio); $this->assertEquals('PersonalDataPerson', $pdata->type); $this->assertEquals('+7 495 6680903', $pdata->phone); $this->assertEquals($account->id, $pdata->account); }