Documentation

DefaultEnumPropertyTest extends AbstractEnumPropertyTest

For Enum testing.

value comparisons may not be the same object instance and additional type checks are necessary.

Table of Contents

createProperty() Creates a property to test IProperty
getPropertyType() Retrieve the property type to test IPropertyType
getValue() Returns some value to test. mixed
getValue2() Returns a second value to test. mixed
testSetValueThrowsValidationException() Tests that setValue throws a ValidationException when supplied with an invalid value void
testSetValueThrowsValidationExceptionWhenSuppliedWithOtherEnumInstance() Tests that setValue throws a ValidationException when supplied with an instance of IEnum that does not match the type contained within the property. void
testSetValueAcceptsEnumInstanceOfSameType() Tests that setValue accepts an instance of IEnum that matches the type stored in the property. mixed
testGetDefaultValue() Tests that the default value is property assigned and returned when creating a property. void
testGetSetValue() Tests the setValue() and getValue() methods. void
testReset() This must be called immediately after object creation and/or if you just want to reset the internal state of the property. void
createProperty() Creates a property to test IProperty
getPropertyType() Retrieve the property type to test IPropertyType
getValue() Returns some value to test. mixed
getValue2() Returns a second value to test. mixed
testGetName() Tests the getName method. void
testGetType() Tests the getType method. void
testGetFlags() Tests the getFlags() method. void
testGetPropertyBehavior() Tests the getPropertyBehavior() method. void
testValidateNullException() Tests that validating null on a property that does not accept null values throws a ValidationException void
testValidateBehaviorCallback() Sets a validation behavior callback that purposely fails. void
testValidate() Tests the validate method. void
testValidateNullThrowsException() Test that validating null on a property that does not accept null throws a ValidationException void
testMagicClone() Property cloning is required. void
makeProperty() Calls createProperty()->reset(); IProperty

Methods

createProperty()

Creates a property to test

protected createProperty( $name : string , $type : IPropertyType , $flags : IPropertyFlags , $behavior : IPropertyBehavior , $defaultValue : mixed ) : IProperty
Parameters
$name : string

Property name

$type : IPropertyType

Property type

$flags : IPropertyFlags

Property flag set

$behavior : IPropertyBehavior

Property behavior callbacks

$defaultValue : mixed

Default property value

Return values
IProperty

instance to test

getPropertyType()

Retrieve the property type to test

protected getPropertyType( ) : IPropertyType
Return values
IPropertyType

type

getValue()

Returns some value to test.

protected getValue( ) : mixed

This must be of the appropriate type. DO NOT RETURN NULL.

Return values
mixed

value

getValue2()

Returns a second value to test.

protected getValue2( ) : mixed

This must be of the appropriate type. DO NOT RETURN NULL.

Return values
mixed

value

testSetValueThrowsValidationException()

Tests that setValue throws a ValidationException when supplied with an invalid value

public testSetValueThrowsValidationException( ) : void

testSetValueThrowsValidationExceptionWhenSuppliedWithOtherEnumInstance()

Tests that setValue throws a ValidationException when supplied with an instance of IEnum that does not match the type contained within the property.

public testSetValueThrowsValidationExceptionWhenSuppliedWithOtherEnumInstance( ) : void

testSetValueAcceptsEnumInstanceOfSameType()

Tests that setValue accepts an instance of IEnum that matches the type stored in the property.

public testSetValueAcceptsEnumInstanceOfSameType( ) : mixed
Return values
mixed

testGetDefaultValue()

Tests that the default value is property assigned and returned when creating a property.

public testGetDefaultValue( ) : void

Also tests the IPropertyBehavior init callback where the default value can be modified.

testGetSetValue()

Tests the setValue() and getValue() methods.

public testGetSetValue( ) : void

Ensures that values are valid, and throws exceptions if not. Tests IPropertyBehavior setter for overriding or modifying values

testReset()

This must be called immediately after object creation and/or if you just want to reset the internal state of the property.

public testReset( ) : void

The IPropertyBehavior init callback is also utilized. The init callack is tested in testGetDefaultValue()

createProperty()

Creates a property to test

protected abstract createProperty( $name : string , $type : IPropertyType , $flags : IPropertyFlags , $behavior : IPropertyBehavior , $defaultValue : mixed ) : IProperty
Parameters
$name : string

Property name

$type : IPropertyType

Property type

$flags : IPropertyFlags

Property flag set

$behavior : IPropertyBehavior

Property behavior callbacks

$defaultValue : mixed

Default property value

Tags
abstract
Return values
IProperty

instance to test

getPropertyType()

Retrieve the property type to test

protected abstract getPropertyType( ) : IPropertyType
Tags
abstract
Return values
IPropertyType

type

getValue()

Returns some value to test.

protected abstract getValue( ) : mixed

This must be of the appropriate type. DO NOT RETURN NULL.

Tags
abstract
Return values
mixed

value

getValue2()

Returns a second value to test.

protected abstract getValue2( ) : mixed

This must be of the appropriate type. DO NOT RETURN NULL.

Tags
abstract
Return values
mixed

value

testGetName()

Tests the getName method.

public testGetName( ) : void

Expects the same name to be returned

testGetType()

Tests the getType method.

public testGetType( ) : void

Expects an IPropertyType instance

testGetFlags()

Tests the getFlags() method.

public testGetFlags( ) : void

Expects an IPropertyFlags instance

testGetPropertyBehavior()

Tests the getPropertyBehavior() method.

public testGetPropertyBehavior( ) : void

Expects an IPropertyBehavior instance or null

testValidateNullException()

Tests that validating null on a property that does not accept null values throws a ValidationException

public testValidateNullException( ) : void

testValidateBehaviorCallback()

Sets a validation behavior callback that purposely fails.

public testValidateBehaviorCallback( ) : void

Tests that validation throws a ValidationException due to the behavior callback.

testValidate()

Tests the validate method.

public testValidate( ) : void

Passes this->getValue() as the first value Passing null without the SPropertyFlags::USE_NULL flag enabled throws an exception PropertyBehavior validate method returns false and throws an exception calls validateImplementation() to test implementation-specific validation

testValidateNullThrowsException()

Test that validating null on a property that does not accept null throws a ValidationException

public testValidateNullThrowsException( ) : void

testMagicClone()

Property cloning is required.

public testMagicClone( ) : void

This ensures that the internals are properly cloned.

makeProperty()

Calls createProperty()->reset();

protected final makeProperty( $name : string , $type : IPropertyType , $flags : IPropertyFlags , $behavior : IPropertyBehavior , $defaultValue : type ) : IProperty
Parameters
$name : string
$type : IPropertyType
$flags : IPropertyFlags
$behavior : IPropertyBehavior
$defaultValue : type
Tags
final
Return values
IProperty

Search results