Perforce Chronicle 2012.2/486814
API Documentation

Workflow_Test_ConditionsTest Class Reference

Test workflow conditions infrastructure. More...

List of all members.

Public Member Functions

 testConditionEvaluate ()
 Test evaluate() method.
 testConditionIsNegated ()
 Test isNegated() method.
 testConditionLoader ()
 Exercise the condition loader.
 testConditionSetGetOptions ()
 Test (set/get)Options() methods.

Detailed Description

Test workflow conditions infrastructure.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Workflow_Test_ConditionsTest::testConditionEvaluate ( )

Test evaluate() method.

    {
        $class = Workflow_Module::getPluginLoader('condition')->load('false');

        $condition = new $class;
        $this->assertFalse(
            $condition->evaluate(new Workflow_Model_Transition, new P4Cms_Content),
            "Expected evaluate to false."
        );

        $condition = new $class(array('negate' => true));
        $this->assertTrue(
            $condition->evaluate(new Workflow_Model_Transition, new P4Cms_Content),
            "Expected evaluate to true if condition is negated."
        );
    }
Workflow_Test_ConditionsTest::testConditionIsNegated ( )

Test isNegated() method.

    {
        $class = Workflow_Module::getPluginLoader('condition')->load('false');

        $condition = new $class;
        $this->assertFalse(
            $condition->isNegated(),
            "Expected condition is not negated."
        );

        $condition->setOptions(array(Workflow_ConditionAbstract::OPTION_NEGATE => true));
        $this->assertTrue(
            $condition->isNegated(),
            "Expected condition is negated."
        );
    }
Workflow_Test_ConditionsTest::testConditionLoader ( )

Exercise the condition loader.

    {
        $loader = Workflow_Module::getPluginLoader('condition');

        $this->assertTrue($loader instanceof Zend_Loader_PluginLoader);
        $this->assertTrue(count($loader->getPaths()) > 0);

        // ensure loader is made, but once.
        $this->assertSame(
            spl_object_hash($loader),
            spl_object_hash(Workflow_Module::getPluginLoader('condition'))
        );

        // ensure we can clear it to regenerate loader.
        Workflow_Module::clearPluginLoaders();
        $this->assertNotSame(
            spl_object_hash($loader),
            spl_object_hash(Workflow_Module::getPluginLoader('condition'))
        );

        // ensure we can resolve the class name of our test condition.
        $this->assertSame(
            'Workflow_Workflow_Condition_False',
            $loader->load('false')
        );
    }
Workflow_Test_ConditionsTest::testConditionSetGetOptions ( )

Test (set/get)Options() methods.

    {
        $class = Workflow_Module::getPluginLoader('condition')->load('false');

        $condition = new $class;
        $this->assertSame(
            array(),
            $condition->getOptions(),
            "Expected empty condition options by default."
        );

        // pass options via constructor
        $options   = array('opt1' => 'a', 'opt2' => array(1, 2, 3), 'opt3' => false);
        $condition = new $class($options);
        $this->assertSame(
            $options,
            $condition->getOptions(),
            "Expected condition options #1."
        );

        // pass options via setOptions
        $condition = new $class;
        $condition->setOptions($options);
        $this->assertSame(
            $options,
            $condition->getOptions(),
            "Expected condition options #2."
        );
    }

The documentation for this class was generated from the following file: