Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2011
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.35 KB | None | 0 0
  1. <?php
  2.  
  3. class Frontend_Registration_CompanyControllerTest extends ControllerTestCase
  4. {
  5.     public function testAddActionSendPost()
  6.     {
  7.         $data = array(
  8.             'www' => 'www.ya-huya.ru',
  9.             'company' => md5(microtime()),
  10.             'forma_id' => '1',
  11.             'telephone' => mt_rand(),
  12.             'country_id' => 3159,
  13.             'region_id' => 4312,
  14.             'city_id' => 4400,
  15.             'street' => mt_rand(),
  16.             'house' => mt_rand(),
  17.             'building' => mt_rand(),
  18.             'flat' => mt_rand(),
  19.             'password' => mt_rand(),
  20.             'email' => 'testemail@testemail.ru',
  21.             'sub_type_id' => array(1, 2),
  22.         );
  23.  
  24.         $this->getRequest()->setMethod('post')->setParams($data);
  25.         $this->dispatch('/registration');
  26.         $this->assertNoErrors();
  27.  
  28.         $user_table = User::getInstance();
  29.         $user = $user_table->selectBy('email', $data['email'])->fetchRow();
  30.         $this->assertNotNull($user);
  31.         $this->assertEquals(4, $user->role_id);
  32.         $this->assertEquals('off', $user->status);
  33.         $this->assertEquals(md5($data['password']), $user->password);
  34.  
  35.         $company = $user->findParentRow('User_Company');
  36.         $this->assertEquals($data['company'], $company->company);
  37.         $this->assertEquals($data['forma_id'], $company->forma_id);
  38.  
  39.         $this->assertEquals(1, sizeof($user->findDependentRowset('User_Company_Type')));
  40.         $this->assertEquals(2, sizeof($user->findDependentRowset('User_Company_SubType')));
  41.  
  42.         $location = $company->findParentRow('User_Company_Location');
  43.         $this->assertEquals(1, $location->is_main);
  44.         $this->assertEquals($data['country_id'], $location->country_id);
  45.         $this->assertEquals($data['region_id'], $location->region_id);
  46.         $this->assertEquals($data['city_id'], $location->city_id);
  47.         $this->assertEquals($data['street'], $location->street);
  48.         $this->assertEquals($data['house'], $location->house);
  49.         $this->assertEquals($data['building'], $location->building);
  50.         $this->assertEquals($data['flat'], $location->flat);
  51.  
  52.     }
  53.  
  54.     public function testAddAction()
  55.     {
  56.         $this->dispatch('/registration');
  57.         $this->assertModuleFromParams('registration');
  58.         $this->assertControllerFromParams('company');
  59.         $this->assertActionFromParams('add');
  60.         $this->assertNoErrors();
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement