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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:01:42+00:00 2026-05-15T11:01:42+00:00

I am diving into the world of unit testing. And i am sort of

  • 0

I am diving into the world of unit testing. And i am sort of lost. I learned today that unit testing is testing if a function works.

I wanted to test the following function:

public function getEventById($id)
{
    return $this->getResource('Event')->getEventById($id);
}

So i wanted to test this function as follows:

public function test_Event_Get_Event_By_Id_Returns_Event_Item()
{
    $p = $this->_model->getEventById(42);
    $this->assertEquals(42, EventManager_Resource_Event_Item_Interface);
    $this->assertType('EventManager_Resource_Event_Item_Interface', $p);
}

But then I got the error:

1) EventTest::test_Event_Get_Event_By_Id_Returns_Event_Item
Zend_Db_Table_Exception: No adapter found for EventManager_Resource_Event

/home/user/Public/ZendFramework-1.10.1/library/SF/Model/Abstract.php:101
/var/www/nrka2/application/modules/eventManager/models/Event.php:25

But then someone told me that i am currently unit testing and not doing an integration test. So i figured that i have to test the function getEventById on a different way. But I don’t understand how.
What this function does it just cals a resource and returns the event by id.

  • 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-15T11:01:42+00:00Added an answer on May 15, 2026 at 11:01 am

    Well, one way is by overloading the object you’re testing. Then you can override the getResource() method to return a “Mock” object (one that always behaves deterministically, and that you can “set up” for each test). The trick is to isolate the functionality that you want to test, and remove any dependencies that may get in the way (the getResource method in your case)…

    I’d recommend reading some tutorials (not just one, a few), and trying to understand the philosophy as well as the methodology…

    Some Tutorials:

    Zend Developer Zone

    PHP Unit Slideshow

    Pragmatic Unit Testing (Note, this is for C#, but the concepts should be the same)

    DevShed

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

Sidebar

Related Questions

I'm diving into unit testing and I would like to know if it is
I am diving into the world of packaging Python applications and managed to get
I'm diving into the world of prolog headfirst but I seem to have hit
I just started diving into the world of Rails by reading the well known
I just recently started diving into Real World Haskell and the book provides some
I'm just diving into the exciting world of facebook app creation, but have already
I've just started diving in to the crazy world that is perl and have
I am guessing that not all SQL is created equally. I am diving into
I just started diving into Metro Style application development and I realized that there
I'm diving into iOS development and I find that for each of my UI

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.