Xdebug can debug codeception but not codeception tests - symfony

I am running Codeception tests in a Symfony2 project and I am developing in PHPstorm.
Debugging codeception used to work, but i recently started a new project it doesn't anymore. Everything is configured as it should. When I set phpstorm to start listening for connections, and I set a breakpoint in bin/codecept. The debugger halts at the breakpoint (as it should).
But when I set the breakpoint in a test (which is definetly ran), I get the message
16:10:41 Debug session was finished without being paused
It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
To figure out the problem check path mappings configuration for 'null' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).
Do not show again (show balloon)
I do believe that something is going wrong with the path mapping, because my server is running on a symlink, but why does debugging app/console and codeception itself work, but not the tests ?

Probably because of this:
https://github.com/Codeception/Codeception/issues/1636#issuecomment-71205765
test is not executed directly, it is triggered from reflection.

Related

Debug Meteor Velocity Mocha tests

I want to debug my test using Velocity and Mocha, using breakpoints and REPL instead of console.logs.
For debugging my app code I can start my Meteor app with the NODE_OPTIONS='--debug' flag, and then bind the debugger like node debug localhost:5858. This doesn't work for the mirror, although its log says debugger listening on port 5858 (both main app and mirror logs say that).
How can I debug it?
Use meteor debug instead of meteor run to start your meteor application. It will add the node inspector package to your running Meteor app so that you can debug it. Node inspector works by hooking into your running Meteor server

Meteor Up (mup) on EC2 Deployment Different from Local App

On localhost, the app works just fine.
On EC2, the app runs behind nginx. It loads into the browser, but nothing shows up. The browser console displays an Error
TypeError: 'undefined' is not an object (evaluating 'Package["service-configuration"].ServiceConfiguration')
I have no idea how to tackle this problem. Any help appreciated.
EDIT
NGINX is not the problem. The same behavior if I access meteor server directly.
Running "meteor add service-configuration" does fix the above mentioned error, but the absence of the error does not fix the observed behavior, that the app does not render on EC2 whereas it does render when started on localhost. (The error message was the only visible difference between EC2 and localhost. So I suspected that would be the cause. Now that hypothesis must be wrong.) So the problem still persists.
Problem Solved. The Lesson:
Meteor has a debug mode and a production mode. The two may behave differently. On localhost, meteor runs in debug mode per default. On deploy to meteor.com or per mup, the default is production mode. To run meteor in production mode on localhost, run meteor --production.
It looks like you're trying to access the service-configuration configs on your browser.
These are not available client side. This also affects your localhost app but it doesn't break your app (doesn't give you a blank page) because meteor is in debug mode.
In debug mode Meteor files are not concatenated so an error like this would go unnoticed, even if it is thrown on your js console. In production mode the error would halt the rest of your script (since everything is concatenated into a single file)
You need to ensure the code that is doing this only runs on the server side. In general it's not a good idea to have access to the service configuration data on the client side.
Looks like Arunoda and crew are adding a buildOptions.debug setting to the next version of MUP, which should allow you to deploy via MUP and have it act like it's running on localhost. See Arunoda's answer to a related question and (at least for now) documentation for the development version of MUP.

Symfony2 test client not firing Xdebug during PHPUnit test in PhpStorm

I've run into an interesting and frustrating wrinkle in attempting to run some functional tests on a Symfony2 project I inherited. I'm sending a POST request to one of my controller methods via Symfony's test client. The debugger works during the test on the test file itself. I can set a break point, run the test, and the debugger will stop all processing at that point until I step through.
The problem is that the debugger does not work in the code that's accessed by the client request, likely because it is a secondary request/session.
Is there a way around this? I'm using PhpStorm 7.1.3, if that matters.
Solved it with the help of this post and supplying the Symfony test client with the right URI.

Debug a PHPUnit test with xdebug using DBGP Proxy

We use DBGP Proxy for making xdebug works with multiple hosts.
To debug a page, i create a run/debug configuration (PHP Web Application) and add the XDEBUG_SESSION_START=mykey to the start URL like this:
Then i push the Run button (if i push Debug button, PHPStorm will add an other XDEBUG_SESSION_START with a random value), and it works.
Now, i want to debug some PHPUnit test so I've created a "PHPUnit on Server" configurations.
The test is launched correctly, but i can't debug it. When i launch a debug, PHPStorm generate a key for the Xdebug session, and don't use 'mykey'.
How can i force PHPStorm to set the XDEBUG_SESSION_START with the value i want?
I try to create a PHP Remote Debug like this:
Once launched, i run the test, but PHPStorm launch a new Xdebug session with a random id...

Delayed_Job NoMethodError when using Nginx

I'm having trouble implementing the Delayed_Job_Active_Record gem in my Production Environment with Nginx. The user submits a 'Contact Us' form, the relevant controller action is called by Nginx and the following line of code fails:
#contact.delay.send_contact_form
Where the relevant method is:
def send_contact_form
ContactMailer.contact_us(self).deliver
end
Development Env: OK
On my local machine I have the pages served by Webrick. Everything runs fine, the delayed jobs go through the 'Delayed_Jobs' table and emails are sent.
Production Env - Rails Console: OK
On the server if I create #contact and call #contact.delay.send_contact_form manually, the delayed job goes through the delayed job table and email is sent.
Production Env - Webrick: OK
On the server if I start up a rails Webrick server I and enter the data for #contact via the web interface and then submit the job goes through the delayed job table and email is sent.
Production Env - Nginx: ERROR
The application is currently served by Nginx.
If I visit the interface via Nginx and enter the data for #contact and submit the page hangs.
The Production Log gives the following error on the controller action, (referencing the line above):
NoMethodError (undefined method `delay' for #< Contact:0x000000052962b0>)
I have also confirmed that the versions of Rails, Ruby and the Delayed_Job_Active_Record and Daemons gems are the same in both environments.
Any help would be greatly appreciated as i've been stuck on this one for a while. I want to find a solution that works with Nginx and which gives me the same functionality as 'Delayed Job'.
Thanks.
It turns out the problem was with Unicorn/Nginx not being restarted upon deployment of code updates, leaving them with incorrect configurations. The problem also occurred when adding Devise and other gems to the application.
The solution initially was to log into the VPS shell after a deployment, (via Capistrano) and run the following:
Restart Unicorn:
/etc/init.d/unicorn_esg stop
/etc/init.d/unicorn_esg start
Where *unicorn_esg* is the Unicorn reference to the application used in my deploy.rb configuration.
Restart Nginx:
sudo service nginx restart
The next step would be to incorporate this into the end of the deploy.rb script so it is automatically run at the end of each deployment.

Resources