Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 862461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:08:48+00:00 2026-05-15T09:08:48+00:00

I am having trouble getting my filters/validators to work correctly on my form, so

  • 0

I am having trouble getting my filters/validators to work correctly on my form, so I want to create a Unit test to verify that the data I am submitting to my form is being filtered and validated correctly.

I started by auto-generating a PHPUnit test in Zend Studio, which gives me this:

<?php
require_once 'PHPUnit/Framework/TestCase.php';

/**
 * Form_Event test case.
 */
class Form_EventTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var Form_Event
     */
    private $Form_Event;
    /**
     * Prepares the environment before running a test.
     */
    protected function setUp ()
    {
        parent::setUp();
        // TODO Auto-generated Form_EventTest::setUp()
        $this->Form_Event = new Form_Event(/* parameters */);
    }
    /**
     * Cleans up the environment after running a test.
     */
    protected function tearDown ()
    {
        // TODO Auto-generated Form_EventTest::tearDown()
        $this->Form_Event = null;
        parent::tearDown();
    }
    /**
     * Constructs the test case.
     */
    public function __construct ()
    {    // TODO Auto-generated constructor
    }
    /**
     * Tests Form_Event->init()
     */
    public function testInit ()
    {
        // TODO Auto-generated Form_EventTest->testInit()
        $this->markTestIncomplete(
        "init test not implemented");
        $this->Form_Event->init(/* parameters */);
    }
    /**
     * Tests Form_Event->getFormattedMessages()
     */
    public function testGetFormattedMessages ()
    {
        // TODO Auto-generated Form_EventTest->testGetFormattedMessages()
        $this->markTestIncomplete(
        "getFormattedMessages test not implemented");
        $this->Form_Event->getFormattedMessages(/* parameters */);
    }
}

so then I open up terminal, navigate to the directory, and try to run the test:

$ cd my_app/tests/unit/application/forms
$ phpunit EventTest.php

Fatal error: Class 'Form_Event' not found in .../tests/unit/application/forms/EventTest.php on line 19

So then I add a require_once at the top to include my Form class and try it again. Now it says it can’t find another class. I include that one and try it again. Then it says it can’t find another class, and another class, and so on. I have all of these dependencies on all these other Zend_Form classes. What should I do? How should I go about testing my Form to make sure my Validators and Filters are being attached correctly, and that it’s doing what I expect it to do. Or am I thinking about this the wrong way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:08:49+00:00Added an answer on May 15, 2026 at 9:08 am

    you have to use your Zend Framework Application Configuration altough for your Unittests. If you work with the “XML” Config of PHPUnit add an Bootstrap File wich runs before the tests are executed.

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit bootstrap="TestConfig.php">
        <testsuite name="XY">
            <directory>./</directory>
        </testsuite>
    </phpunit>
    

    In your TestConfig.php setup the AutoLoader and other needed ressources, or use the config.ini from your Application like in my example.

    $includeConfig = parse_ini_file(TEST_PATH . '/config/config.ini', true);
    
    set_include_path(
        implode(PATH_SEPARATOR, $includeConfig['includes'])
        . PATH_SEPARATOR
        . TEST_PATH . PATH_SEPARATOR
        . get_include_path()
    );
    unset($includeConfig);
    
    require_once 'Zend/Loader/Autoloader.php';
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace('App_');
    

    If you need more hints check out this Tutorial on Zend Framework with PHPUNIT
    PHPUnit + Zend Framework

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting a filter to work on a BindingSource that is the
I am having trouble getting my query by criteria to work. I want to
I'm having trouble getting a rotary encoder to work properly with AVR micro controllers.
I'm having trouble getting the following to work in SQL Server 2k, but it
I'm having trouble getting in touch with SQL Server Managemen Studio 2008! I want
I'm having masses of trouble getting an ObjectDataProvider work with method parameters. Now with
Having trouble getting JQuery to access the parent form field 'inputStart's value when a
I've done this before, but I'm having trouble getting this to work... I need
Having trouble getting my POST arrays to show all checkbox values from my form.
Having trouble getting the id of divs on my page that begin with refresh.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.