public function testCollectionSelect()
 {
     $roles = array(new MockRole('root', 'SuperAdmin'), new MockRole('admin', 'Administrator'), new MockRole('user', 'SimpleUser'));
     $user = new MockUser('John Doe', 2);
     $this->assertDomEqual(collection_select('user', 'role', $user, $roles, 'flag', 'lib'), '<select id="user_role" name="user[role]">
         <option value="root">SuperAdmin</option>
         <option value="admin">Administrator</option>
         <option value="user">SimpleUser</option>
         </select>');
     $user = new MockUser('John Doe', 2, 'root');
     $this->assertDomEqual(collection_select('user', 'role', $user, $roles, 'flag', 'lib'), '<select id="user_role" name="user[role]">
         <option value="root" selected="selected">SuperAdmin</option>
         <option value="admin">Administrator</option>
         <option value="user">SimpleUser</option>
         </select>');
     $user = new MockUser('John Doe', 2);
     $this->assertDomEqual(collection_select('user', 'role', $user, $roles, 'flag', 'lib', array('include_blank' => true)), '<select id="user_role" name="user[role]">
         <option value=""></option>
         <option value="root">SuperAdmin</option>
         <option value="admin">Administrator</option>
         <option value="user">SimpleUser</option>
         </select>');
     $user = new MockUser('John Doe', 2);
     $this->assertDomEqual(collection_select('user', 'role', $user, $roles, 'flag', 'lib', array('prompt' => 'Please select')), '<select id="user_role" name="user[role]">
         <option value="">Please select</option>
         <option value="root">SuperAdmin</option>
         <option value="admin">Administrator</option>
         <option value="user">SimpleUser</option>
         </select>');
     $user = new MockUser('John Doe', 2, 'user');
     $this->assertDomEqual(collection_select('user', 'role', $user, $roles, 'flag', 'lib', array('prompt' => 'Please select')), '<select id="user_role" name="user[role]">
         <option value="root">SuperAdmin</option>
         <option value="admin">Administrator</option>
         <option value="user" selected="selected">SimpleUser</option>
         </select>');
 }
Ejemplo n.º 2
0
 /**
  *  @todo Write test for collection_select()
  */
 public function testCollection_select()
 {
     echo collection_select(null, null, null, null, null);
     // Remove the following line when you implement this test.
     throw new PHPUnit2_Framework_IncompleteTestError();
 }
Ejemplo n.º 3
0
 public function collection_select($method, $collection, $valueProp, $textProp, $options = array(), $htmlOptions = array())
 {
     return collection_select($this->objectName, $method, $this->object, $collection, $valueProp, $textProp, $options, $htmlOptions);
 }