Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Frontend_Registration_CompanyControllerTest extends ControllerTestCase
- {
- public function testAddActionSendPost()
- {
- $data = array(
- 'www' => 'www.ya-huya.ru',
- 'company' => md5(microtime()),
- 'forma_id' => '1',
- 'telephone' => mt_rand(),
- 'country_id' => 3159,
- 'region_id' => 4312,
- 'city_id' => 4400,
- 'street' => mt_rand(),
- 'house' => mt_rand(),
- 'building' => mt_rand(),
- 'flat' => mt_rand(),
- 'password' => mt_rand(),
- 'email' => 'testemail@testemail.ru',
- 'sub_type_id' => array(1, 2),
- );
- $this->getRequest()->setMethod('post')->setParams($data);
- $this->dispatch('/registration');
- $this->assertNoErrors();
- $user_table = User::getInstance();
- $user = $user_table->selectBy('email', $data['email'])->fetchRow();
- $this->assertNotNull($user);
- $this->assertEquals(4, $user->role_id);
- $this->assertEquals('off', $user->status);
- $this->assertEquals(md5($data['password']), $user->password);
- $company = $user->findParentRow('User_Company');
- $this->assertEquals($data['company'], $company->company);
- $this->assertEquals($data['forma_id'], $company->forma_id);
- $this->assertEquals(1, sizeof($user->findDependentRowset('User_Company_Type')));
- $this->assertEquals(2, sizeof($user->findDependentRowset('User_Company_SubType')));
- $location = $company->findParentRow('User_Company_Location');
- $this->assertEquals(1, $location->is_main);
- $this->assertEquals($data['country_id'], $location->country_id);
- $this->assertEquals($data['region_id'], $location->region_id);
- $this->assertEquals($data['city_id'], $location->city_id);
- $this->assertEquals($data['street'], $location->street);
- $this->assertEquals($data['house'], $location->house);
- $this->assertEquals($data['building'], $location->building);
- $this->assertEquals($data['flat'], $location->flat);
- }
- public function testAddAction()
- {
- $this->dispatch('/registration');
- $this->assertModuleFromParams('registration');
- $this->assertControllerFromParams('company');
- $this->assertActionFromParams('add');
- $this->assertNoErrors();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement