[fw-general] PHPUnit is only dispatching default module, why?
I have been trying to solve this for two days and need some help. I'm new to PHPUnit and unit testing in general. My problem is that when I do a dispatch it will only use the default module, or that is what I believe is happening. I'm supplying code from my bootstrap, and the test files. My directory structures and the two methods first one fails And the second one passes. The login process is working from the web pages. When I run this test case: public function testLoginControllerHasLoginAction(){ $this->dispatch('/mttauthacl/login/login'); $this->assertModule('mttauthacl'); $this->assertController('login'); $this->assertAction('login'); } It fails on "$this->assertModule('mttauthacl');" with a failure of : Failed asserting last module used <"default"> was "mttauthacl". When I run this next test method it passes: public function testWhenLayoutHasLoginFormButton(){ $this->dispatch('/default/index'); $this->assertAction('index'); $this->assertQueryCount('#loginbtn', 1); } Which is what leads me to believe the test environment is not seeing my module path for some reason. The application and the testing directories are set up the same as described below. APP Directory Structure: /application/modules/mttauthacl/controllers Testing ENV Directory Structure /tests/application/modules/mttauthacl/controllers My test file is LoginControllerTest.php and the cod === = LoginControllerTest. Start= === require_once 'PHPUnit/Framework/TestCase.php'; if (!defined('APPLICATION_PATH')) { require_once dirname(dirname(dirname(__FILE__))) . '../../../bootstrap.php'; } $autoloader = new Zend_Application_Module_Autoloader( array( 'namespace' => 'Mttauthacl_', 'basePath' => APPLICATION_PATH . '/modules/mttauthacl', ) ); class Mttauthacl_LoginControllerTest extends Zend_Test_PHPUnit_ControllerTestCase { private $_authService; private $_loginForm; private $_loginEmail; private $_password; public function setUp(){ /* Setup Routine */ $this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); parent::setUp(); } = LoginControllerTest. End = == = Bootstrap Start = === error_reporting(E_ALL | E_STRICT); // Define root path of project defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__) . '/../')); // 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/Loader/Autoloader.php'; $loader = Zend_Loader_Autoloader::getInstance(); === -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/PHPUnit-is-only-dispatching-default-module-why-tp3572200p3572200.html Sent from the Zend Framework mailing list archive at Nabble.com.
RE: [fw-general] view->getHelper in try..catch but still getting exception
Just for the archives in case someone else runs in to the same problem, I had the following on in the xdebug.ini settings xdebug.show_exception_trace = On Which does what it says - lol Terre -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
RE: [fw-general] view->getHelper in try..catch but still getting exception
I looked for any set_error_handler functions but didn't find any. I next made a base zend project and put only that code in it and got the error still, so then I started pondering it a bit more and looking at the server settings. I have traced it down to xdebug running on the server, if I turn that off the errors are caught in the try..catch block. Likely some setting in there with xdebug is wrong. Thanks for the replys, they got me thinking about it differently. Terre -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
Re: [fw-general] view->getHelper in try..catch but still getting exception
I'd guess, that the helper is requested somewhere before the try/catch block. Double check the line number in the exception's stack trace ;) On Fri, Jun 3, 2011 at 9:46 PM, Matthew Weier O'Phinney wrote: > -- Terre Porter wrote > (on Friday, 03 June 2011, 03:07 PM -0400): > > I would like to use something like this : > > > > > > > > $helper = > > $this->view->getHelper($helpername); > > > > > > > > But I would like to confirm the helper exists. So I've tried the above > but > > since the getHelper only seems to toss an error instead of returning null > or > > something I added in this. > > > > > > > > try { > > > > $helper = > > $this->view->getHelper('inoexists'); > > > > } catch > > (Zend_Loader_PluginLoader_Exception $e) { > > > > // do > > something here about the error > > > > } > > > > But I still get the error: > > > > > > > > Zend_Loader_PluginLoader_Exception: Plugin by name 'Inoexists' was not > found > > in the registry; used paths: Zend_View_Helper_: > > > Zend/View/Helper/:./views/helpers/:/home/cmsdev/application/library/Core/Hel > > pers/:/home/cmsdev/application/modules/default/views/helpers/ in > > /home/cmsdev/includes/Zend/Loader/PluginLoader.php on line 412 > > > Um, it works for me? > > Do you by any chance have an exception handler registered in your > application? That may be intercepting it pre-catch. > > > > Anyone know why it is not being caught by the try block? Or a > > suggestion on how to fix it. > > -- > Matthew Weier O'Phinney > Project Lead| matt...@zend.com > Zend Framework | http://framework.zend.com/ > PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > > >
Re: [fw-general] view->getHelper in try..catch but still getting exception
-- Terre Porter wrote (on Friday, 03 June 2011, 03:07 PM -0400): > I would like to use something like this : > > > > $helper = > $this->view->getHelper($helpername); > > > > But I would like to confirm the helper exists. So I've tried the above but > since the getHelper only seems to toss an error instead of returning null or > something I added in this. > > > > try { > > $helper = > $this->view->getHelper('inoexists'); > > } catch > (Zend_Loader_PluginLoader_Exception $e) { > > // do > something here about the error > > } > > But I still get the error: > > > > Zend_Loader_PluginLoader_Exception: Plugin by name 'Inoexists' was not found > in the registry; used paths: Zend_View_Helper_: > Zend/View/Helper/:./views/helpers/:/home/cmsdev/application/library/Core/Hel > pers/:/home/cmsdev/application/modules/default/views/helpers/ in > /home/cmsdev/includes/Zend/Loader/PluginLoader.php on line 412 Um, it works for me? Do you by any chance have an exception handler registered in your application? That may be intercepting it pre-catch. > Anyone know why it is not being caught by the try block? Or a > suggestion on how to fix it. -- Matthew Weier O'Phinney Project Lead| matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: Zend_Rest_Controller - Retrieve PUT data
Hi George, I write a controller helper to retrieve data inside PUT and DELETE actions. I don't say its the best way but solve our problems. https://github.com/lab2023/kebab-project/blob/master/library/Kebab/Controller/Helper/Param.php Regards. -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Rest-Controller-Retrieve-PUT-data-tp3529898p3571262.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: Inserting data into 2 tables in 1 form
David Mintz-3 wrote: > > If you are considering how to conveniently sort out the incoming request > parameters POSTed from your form, you can namespace -- or sort of > psuedo-namespace -- your form vars with a couple of techniques. > > One is use array notation, as in name="tableOne[someOtherField]"> and then all the data meant for table is > available to your controller as an array: $this->_getParam('tableOne'). A > problem arises if one of the form fields itself needs to be an array, but > it > works if the data is scalar. > The same can be achieved using subforms for each table, see the documentation. The form data are then automatically presented as an array of arrays for each subform / table - Second Start Stamrecht BV oprichten -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Inserting-data-into-2-tables-in-1-form-tp653372p3571228.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: Inserting data into 2 tables in 1 form
dele454 wrote: > > and send the exception trace as a log to make the system mail it to > you. - i prefer having to recieve it via email - very convienient. > how do you mail an exception to yourself, I am trying to do that myself but without luck. -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Inserting-data-into-2-tables-in-1-form-tp653372p3570952.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: ZF, Doctrine Integration. i made an architectural error over Models.
@Greg. Thank you very much. I don't wanna make super helper which solved all problem because of Single Responsibility Principle. First example is better than second. I will research projects on Github to finding best practise. -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZF-Doctrine-Integration-i-made-an-architectural-error-over-Models-tp3566283p3570327.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: Send mail with multiple Cc
You can't be getting the same error because the SMTP transport will not throw the same exception. The only exception that the SMTP transport throws is '_prepareHeaders requires a registered Zend_Mail object'. Is that what you're getting? David -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Send-mail-with-multiple-Cc-tp3556120p3570043.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] view->getHelper in try..catch but still getting exception
Hi, I would like to use something like this : $helper = $this->view->getHelper($helpername); But I would like to confirm the helper exists. So I've tried the above but since the getHelper only seems to toss an error instead of returning null or something I added in this. try { $helper = $this->view->getHelper('inoexists'); } catch (Zend_Loader_PluginLoader_Exception $e) { // do something here about the error } But I still get the error: Zend_Loader_PluginLoader_Exception: Plugin by name 'Inoexists' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:./views/helpers/:/home/cmsdev/application/library/Core/Hel pers/:/home/cmsdev/application/modules/default/views/helpers/ in /home/cmsdev/includes/Zend/Loader/PluginLoader.php on line 412 Anyone know why it is not being caught by the try block? Or a suggestion on how to fix it. Thanks Terre
Re: [fw-general] Re: Send mail with multiple Cc
On Jun 3, 2011, at 12:48 PM, whisher wrote: > David Muir wrote: >> >> You can't be getting the same error because the SMTP transport will not >> throw the same exception. The only exception that the SMTP transport >> throws is '_prepareHeaders requires a registered Zend_Mail object'. Is >> that what you're getting? >> >> David >> > > $body = 'Hi all,Alan'; > $mail = new Zend_Mail(); > $mail->setFrom('x...@x.com', 'Alan'); > $mail->addTo('xxx...@gmail.com', 'Alan'); > $mail->addCc(array('human_readable1'=>'x...@b.com','human_readable2'=>'x...@e.com')); > > $mail->setSubject('Basketball practice this week'); > $mail->setBodyText($body); > $tr1 = new Zend_Mail_Transport_Smtp('you@yourserver.local'); $mail->send($tr1); ...to use the SMTP transport and get the other error message. http://framework.zend.com/manual/en/zend.mail.different-transports.html you can also do it like it is explained here, by replacing the default transport http://framework.zend.com/manual/en/zend.mail.sending.html When I used zend_mail the first time, I first ensured the box can send mail [from the console]. Then checked the mta im using from the console is the same one php is set to use `php -i|grep -i mail`. Do an ls -l on the sendmail binary this php is configured to use to find the mta your using if your unsure, you'll have to follow a few links before you get to the end of the trail. If either method to use Zend_Mail does not work and the exception does not seem to give any hints, check your mail logs. I setup postfix as a gmail relay, the local server is set to relay any locally queued mail as that gmail user. The messages that are queued are delivered to gmail via local SMTP relay. "It is essentially a wrapper to the PHP » mail() function." http://framework.zend.com/manual/en/zend.mail.introduction.html#zend.mail.introduction.sendmail look here http://php.net/manual/en/function.mail.php and maybe just try: $ php -r "mail('you@yourserver.local', 'Test Subject', 'Test message');" then tail your maillog Good luck F -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: Inserting data into 2 tables in 1 form
dele454 wrote: > > send the exception trace as a log to make the system mail it to you. > - i prefer having to recieve it via email - very convienient. > how do you mail an exception to yourself, I am trying to do that myself but without luck? - Second Start Stamrecht BV oprichten -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Inserting-data-into-2-tables-in-1-form-tp653372p3571458.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Re: Send mail with multiple Cc
David Muir wrote: > > You can't be getting the same error because the SMTP transport will not > throw the same exception. The only exception that the SMTP transport > throws is '_prepareHeaders requires a registered Zend_Mail object'. Is > that what you're getting? > > David > $body = 'Hi all,Alan'; $mail = new Zend_Mail(); $mail->setFrom('x...@x.com', 'Alan'); $mail->addTo('xxx...@gmail.com', 'Alan'); $mail->addCc(array('human_readable1'=>'x...@b.com','human_readable2'=>'x...@e.com')); $mail->setSubject('Basketball practice this week'); $mail->setBodyText($body); $mail->send(); I got: Fatal error: Uncaught exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. ' in /public_html/library/Zend/Mail/Transport/Sendmail.php:137 Stack trace: #0 /public_html/library/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Sendmail->_sendMail() #1 /public_html/library/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail)) #2 /public_html/www/index.php(46): Zend_Mail->send() #3 {main} thrown in /public_html/library/Zend/Mail/Transport/Sendmail.php on line 137 -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Send-mail-with-multiple-Cc-tp3556120p3571400.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com