Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
ProfileFieldTest.php
1 <?php
2 /**
3  * Created by JetBrains PhpStorm.
4  * User: andrew
5  * Date: 7/16/12
6  * Time: 6:27 PM
7  * To change this template use File | Settings | File Templates.
8  */
9 class ProfileFieldTest extends CDbTestCase
10 {
11  /**
12  * @dataProvider provider
13  */
14  public function testCreate($attributes)
15  {
16  $profileField = new ProfileField();
17  $profileField->attributes = $attributes;
18  $this->assertTrue($profileField->save());
19  }
20 
21  /**
22  * @depends testCreate
23  * @dataProvider provider
24  */
25  public function testFind($attributes)
26  {
27  $profileField = ProfileField::model()->findByAttributes($attributes);
28  $this->assertNotNull($profileField);
29  }
30 
31  /**
32  * @param $attributes
33  * @depends testFind
34  * @dataProvider provider
35  */
36  public function testDelete($attributes)
37  {
38  $this->assertEquals(1, ProfileField::model()->deleteAllByAttributes($attributes));
39  }
40 
41 
42  public function testItemAllias()
43  {
44  $this->assertEquals('INTEGER',ProfileField::itemAlias('field_type', 'INTEGER'));
45  $this->assertTrue(is_array(ProfileField::itemAlias('required')));
46  }
47 
48  public function testGetLabels()
49  {
50  $this->assertNotEmpty(ProfileField::model()->attributeLabels());
51  }
52 
53  public function testSearch()
54  {
55  $this->assertInstanceOf('CActiveDataProvider', ProfileField::model()->search());
56  }
57 
58  public function provider()
59  {
60  return array(
61  array(array(
62  'varname' => 'field1',
63  'title' => 'field1',
64  'field_type' => 'VARCHAR',
65  'field_size' => 255,
66  'field_size_min' => 2,
67  'required' => 1,
68  'match' => '',
69  'range' => 'M==Male;F==Female',
70  'error_message' => 'Incorrect field1',
71  'other_validator' => 'adsasdasd',
72  'default' => 'default value',
73  'position' => 1,
74  'visible' => 1
75  )),
76  array(array(
77  'varname' => 'field2',
78  'title' => 'field2',
79  'field_type' => 'VARCHAR',
80  'field_size' => 255,
81  'field_size_min' => 2,
82  'required' => 1,
83  'match' => '',
84  'range' => 'checkbox-1',
85  'error_message' => '',
86  'other_validator' => 'adsasdasd',
87  'default' => 'default value',
88  'position' => 1,
89  'visible' => 1
90  ))
91  );
92 
93 
94  }
95 
96 
97 }