Documentation

DefaultSetPropertyTest extends AbstractPropertyTest

Tests the AbstractProperty class.

This is currently broken due to the way object comparison is "not" working. Objects that are technically equal may have different internal states, therefore a standard "==" comparison will not work. Furthermore, the internal property object instance may be different than the object supplied to setValue(), so "===" will not work either.

When checking values returned by the property, this needs to take objects into consideration. If objects are being compared, then they should implement the same interfaces, and they should also have the same value when cast to a string. All properties are required to be able to be cast to strings.

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
testValidateBehaviorCallback() Sets a validation behavior callback that purposely fails. 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
testGetDefaultValue() Tests that the default value is property assigned and returned when creating a property. void
testValidateNullThrowsException() Test that validating null on a property that does not accept null throws a ValidationException 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
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

testValidateBehaviorCallback()

Sets a validation behavior callback that purposely fails.

public testValidateBehaviorCallback( ) : void

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

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

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.

testValidateNullThrowsException()

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

public testValidateNullThrowsException( ) : void

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()

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