Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
ProfileTest.php
1 <?php
2 
3 class ProfileTest extends CDbTestCase
4 {
5  public $fixtures = array(
6  'profiles_fields' => 'ProfileField'
7  );
8 
9 
10  public function testGetRules()
11  {
12  $profileField = new Profile();
13  $rules = $profileField->rules();
14  $this->assertNotEmpty(array_filter($rules, function($var){
15  return $var[0] == 'firstname' && $var[1] != 'notContainsTags';
16  }));
17  $this->assertNotEmpty(array_filter($rules, function($var){
18  return $var[0] == 'lastname' && $var[1] != 'notContainsTags';
19  }));
20  $this->assertNotEmpty(array_filter($rules, function($var){
21  return $var[0] == 'birthday' && $var[1] != 'notContainsTags';
22  }));
23  $this->assertNotEmpty(array_filter($rules, function($var){
24  return $var[0] == 'gender' && $var[1] != 'notContainsTags';
25  }));
26  $this->assertNotEmpty(array_filter($rules, function($var){
27  return $var[0] == 'send_me_notifications' && $var[1] != 'notContainsTags';
28  }));
29  $this->assertNotEmpty(array_filter($rules, function($var){
30  return $var[0] == 'private_zip' && $var[1] != 'notContainsTags';
31  }));
32  $this->assertNotEmpty(array_filter($rules, function($var){
33  return $var[0] == 'private_country' && $var[1] != 'notContainsTags';
34  }));
35  $this->assertNotEmpty(array_filter($rules, function($var){
36  return $var[0] == 'private_phone_number' && $var[1] != 'notContainsTags';
37  }));
38  $this->assertNotEmpty(array_filter($rules, function($var){
39  return $var[0] == 'private_mobile_phone' && $var[1] != 'notContainsTags';
40  }));
41 
42  }
43 
44  public function testNotContainsTags()
45  {
46  $profile= new Profile();
47  $profile->firstname = '<h1>tag';
48  $profile->validate();
49  $this->assertEquals('Field shouldn\'t contains any tags',$profile->getError('firstname'));
50 
51  }
52 
53  public function testRange()
54  {
55  $range = Profile::range($this->profiles_fields('gender')->range);
56  $this->assertArrayHasKey('M',$range);
57  $this->assertArrayHasKey('F',$range);
58  }
59 
60  public function testGetWidgetAttributes()
61  {
62  $profile = new Profile();
63  $this->assertArrayHasKey('birthday',$profile->widgetAttributes());
64  }
65 
66  public function testWidgetParams()
67  {
68  $profile = new Profile();
69  $this->assertNotEmpty($profile->widgetParams('birthday'));
70  }
71 
72  public function testSetAttributes()
73  {
74  $profile = new Profile();
75  $profile->setAttributes(array('birthday' => array('defaultDate'=>'+30m')));
76  }
77 }