/** * Incorrect creation tests (attributes and final elements) */ function itest_wrong_creation() { // Create instance with invalid name try { $instance = new mock_base_nested_element(''); $this->fail("Expecting base_atom_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_atom_struct_exception); } // Create instance with incorrect (object) final element try { $obj = new stdClass(); $obj->name = 'test_attr'; $instance = new mock_base_nested_element('TEST', null, $obj); $this->fail("Expecting base_element_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_element_struct_exception); } // Create instance with array containing incorrect (object) final element try { $obj = new stdClass(); $obj->name = 'test_attr'; $instance = new mock_base_nested_element('TEST', null, array($obj)); $this->fail("Expecting base_element_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_element_struct_exception); } // Create instance with array containing duplicate final elements try { $instance = new mock_base_nested_element('TEST', null, array('VAL1', 'VAL2', 'VAL1')); $this->fail("Expecting base_element_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_element_struct_exception); } // Try to get value of base_nested_element $instance = new mock_base_nested_element('TEST'); try { $instance->get_value(); $this->fail("Expecting base_element_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_element_struct_exception); } // Try to set value of base_nested_element $instance = new mock_base_nested_element('TEST'); try { $instance->set_value('some_value'); $this->fail("Expecting base_element_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_element_struct_exception); } // Try to clean one value of base_nested_element $instance = new mock_base_nested_element('TEST'); try { $instance->clean_value('some_value'); $this->fail("Expecting base_element_struct_exception exception, none occurred"); } catch (Exception $e) { $this->assertTrue($e instanceof base_element_struct_exception); } }