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

  • Home
  • SEARCH
  • 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 7758179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:17:27+00:00 2026-06-01T13:17:27+00:00

I have a number of simple controller classes that use Doctrine’s entity manager to

  • 0

I have a number of simple controller classes that use Doctrine’s entity manager to retrieve data and pass it to a view.

public function indexAction() {
    $pages = $this->em->getRepository('Model_Page')->findAll();
    $this->view->pages = $pages;
}

What exactly should we be testing here?

  • I could test routing on the action to ensure that’s configured properly
  • I could potentially test that the appropriate view variables are being set, but this is cumbersome

The findAll() method should probably be in a repository layer which can be tested using mock data, but then this constitutes a different type of test and brings us back to the question of

What should we be testing as part of controller tests?

  • 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-06-01T13:17:29+00:00Added an answer on June 1, 2026 at 1:17 pm

    Controller holds core logic for your application. Though simple “index” controller actions don’t have any specific functions, those that verify/actively use data and generate viewmodels have pretty much the most functionality of the system.

    For example, consider login form. Whenever the login data is posted, controller should validate login/password and return: 1) to index page whenever logins are good. Show welcome,{user} text. 2) to the login page saying that login is not found in db. 3) to the login page saying that password is not found in db.

    These three types of outputs make perfect test cases. You should validate that correct viewmodels/views are being sent back to the client with the appropriate actions.

    You shouldn’t look at a controller like at something mysterious. It’s just another code piece, and it’s tested as any other code – any complicated logic that gives business-value to the user should be tested.

    Also, I’d recommend using acceptance testing with framework like Cucumber to generate meaningful test cases.

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

Sidebar

Related Questions

I have a grid view that has two simple columns, a report number and
Say I have simple program that emulates a board game with a number of
I have a simple Rails 3 application that has a number of models. A
I have a simple ruby on rails project that I'm trying to use a
I have a number of URLs that fit a {controller}/{action} pattern. My problem is
I have a static class called Helpers which contains a good number of simple
I have a simple array with x number of items. I am displaying them
I have 2 simple questions about python: 1.How to get number of lines of
I have a simple file-system-ed-login (not mysql) just to track number of users who
I have the following simple equation in my C# program to convert a number

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.