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 5956123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:12:42+00:00 2026-05-22T18:12:42+00:00

I am using unit test to test zend project, this is application.ini [production] phpSettings.display_startup_errors

  • 0

I am using unit test to test zend project,
this is application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
resources.frontController.params.displayExceptions = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"


; modules
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "layout"
resources.view[] =
resources.view.doctype = "XHTML1_STRICT"

; database
resources.db.adapter = "PDO_MYSQL"
resources.db.params.dbname = "demodev"
resources.db.params.password = "demo_core_pass"
resources.db.params.username = "demo_core_user"
resources.db.params.host = "localhost"
resources.db.isDefaultTableAdapter = true

; session
resources.session.save_path = APPLICATION_PATH "/../data/session"
resources.session.use_only_cookies = true
;resources.session.remember_me_seconds = 10

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

[amsterdam : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

this is the phpunit.xml:

<phpunit bootstrap="./application/bootstrap.php"  colors="true">         
<testsuite>
    <directory>./</directory>       
</testsuite>
<filter>
    <whitelist>
        <directory suffix="MyApp.php">../application/</directory>
        <exclude>
            <file>../application/Bootstrap.php</file>
            <file>../application/controllers/ErrorController.php</file>
            <directory suffix=".phtml">../application/</directory>
        </exclude>
    </whitelist>
</filter>


<logging>
    <log type="coverage-html" target="./log/report" charset="UTF-8"
        yui="true" highlight="true" lowUpperBound="50" highLowerBound="80"/>
    <log type="testdox-html" target="./log/testdox.html" />
</logging>         

this is the bootstrap.php

<?php
error_reporting(E_ALL);

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

require_once 'Zend/Application.php';
require_once 'ControllerTestCase.php';
//require_once 'MyApp.php';

this is the ControllerTestCase.php

<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';

class ControllerTestCase 
    extends Zend_Test_PHPUnit_ControllerTestCase 
{
    protected $application;

    public function setUp() {
        $this->bootstrap = array($this,'appBootstrap');
        parent::setUp();

    }

    public function appBootstrap() {
        $this->application = 
            new Zend_Application(APPLICATION_ENV,
                                 APPLICATION_PATH.'/configs/application.ini');

        $this->application->bootstrap();

    }
}

this is the IndexControllerTest.php

<?php

require_once ‘Zend/Test/PHPUnit/ControllerTestCase.php’;
class IndexControllerTest extends ControllerTestCase
{

public function testHomePage() {
    $this->dispatch('/index');
    $this->assertController('index');
    $this->assertAction('menu');
}

}

when I go the the tests folder, run command phpunit, it gives me this error:

D:\PHP\apache2\htdocs\demo_src\tests>phpunit
PHPUnit 3.5.13 by Sebastian Bergmann.

PHP Fatal error:  Call to a member function hasResource() on a non-object in D:\
PHP\apache2\htdocs\demo_src\application\controllers\ErrorController.php on line
46

Fatal error: Call to a member function hasResource() on a non-object in D:\PHP\a
pache2\htdocs\demo_src\application\controllers\ErrorController.php on line 46

How can I fix this problem?

When I change the IndexControllerTest as one test, such as:

<?php


class IndexControllerTest extends ControllerTestCase
{

    public function testHomePage() {
        $this->assertTrue(true);

    }


}

it works, but when I change it to

<?php

class IndexControllerTest extends ControllerTestCase
{

    public function testHomePage() {
        $this->dispatch('/');

    }
}

The 46 line in ErrorController.php is:

public function getLog() {
        $bootstrap = $this->getInvokeArg('bootstrap');
        if (!$bootstrap->hasResource('Log')) {// this is line 46
            return false;
        }
        $log = $bootstrap->getResource('Log');
        return $log;
    }

it still give me the same error, any suggestion?

  • 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-22T18:12:43+00:00Added an answer on May 22, 2026 at 6:12 pm

    Try with this IndexControllerTest class

    class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
    {
    
        public function setUp()
        {
            $this->bootstrap = new Zend_Application(
                APPLICATION_ENV,
                APPLICATION_PATH . '/configs/application.ini'
            );
            parent::setUp();
        }
    
        public function testHomePage()
        {
            $params = array(
                'action' => 'index',
                'controller' => 'index',
                'module' => 'default'
            );
            $url = $this->url($this->urlizeOptions($params));
            $this->dispatch($url);
    
            // assertions
            $this->assertModule($params['module']);
            $this->assertController($params['index']);
            $this->assertAction($params['action']);
        }
    
    }
    

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

Sidebar

Related Questions

I have a Unit test project for my Application using DUnit framework. This project
I am trying to unit test my Zend Framework application using PHPUnit 3.6.4. I
We are currently using unit tests to test our project. We have the majority
I'm trying to write a unit test for a controller using Zend and PHPUnit
I have a Silverlight testing project using the Silverlight Unit Test Framework . I
I've begun using ASPUnit to unit test my classic ASP code. This is all
I wrote an unit-test using MSTest for my Application which uses functionality from a
I am using .net unit testing in my project. I can unit test, get
I m using Silverlight Unit Test framework for testing my application. The unit testing
I am using python unit test module. I am wondering is there anyway to

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.