I am using the captbariton mailcatcher module for Codeception (https://github.com/captbaritone/codeception-mailcatcher-module). The system
is run on a local XAMPP-installation. I have installed and configured the Mailcatcher module in accepance.suite.xml like this:
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost/development/rd_dev/webroot/
- \Helper\Acceptance
- MailCatcher
config:
MailCatcher:
url: 'http://127.0.0.1'
port: '1080'
In one test I'm sending an email from the system. I print the text that has put in the email that I send on the screen and first check that this is correct. I can manually see the email appear on in the web browser on the address and port: http://127.0.0.1:1080/ and it also works out to use a method to delete all the messages on the mailcatcher smtp-server, $I->resetEmails().
However when I use methods to access the content of the email from the test, for example $I->seeInLastEmail('foo') or $text = $I->grabFromLastEmail("bar"), then I get the error message shown below:
There was 1 error:
---------
1) ACT1050-SendEmailReportReminderWhenTryingOutServiceCept: Send email with report reminder for one report for the test company to an email address specified by the user (act1050)
Test tests/acceptance/ACT1050- SendEmailReportReminderWhenTryingOutServiceCept.php
[GuzzleHttp\Exception\ServerException] Server error: `GET http://127.0.0.1:1080/messages/3.json` resulted in a `500 Internal Server Error` response: Internal server error
Scenario Steps:
36. $I->seeInLastEmail("report") at tests/acceptance/ACT1050-SendEmailReportReminderWhenTryingOutServiceCept.php:31
35. $I->see("sent 2017-07-29") at tests/acceptance/ACT1050-SendEmailReportReminderWhenTryingOutServiceCept.php:30
34. $I->see("report") at tests/acceptance/ACT1050-SendEmailReportReminderWhenTryingOutServiceCept.php:29
33. $I->see("To: carl#example.com") at tests/acceptance/ACT1050-SendEmailReportReminderWhenTryingOutServiceCept.php:28
32. $I->see("This email has been sent") at tests/acceptance/ACT1050-SendEmailReportReminderWhenTryingOutServiceCept.php:27
31. $I->click("Send email") at tests/acceptance/ACT1050-SendEmailReportReminderWhenTryingOutServiceCept.php:26
#1 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/guzzle/src/Middleware.php:65
#2 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:203
#3 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:156
#4 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/TaskQueue.php:61
#5 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:246
#6 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:223
#7 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:266
#8 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:225
#9 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/promises/src/Promise.php:62
#10 /cygdrive/c/xampp/htdocs/bin/vendor/guzzlehttp/guzzle/src/Client.php:129
I have tried to fiddle with the settings for access to directories in httpd.conf-file (and after changed back to normal), but I have not succeded.
Can someone help me with this issue?
Related
So I'm making an automated test with codeception. It was working well using phpbrowser, but the page I want to test uses ajax so I changed to webdriver, following the instructions on the codeception website.
I chose to use chromedriver since I'm only going to be doing this test with chrome, but it's giving me back this error
Acceptance Tests (1) ---------------------------------------------------------------------------------------------------
FirstCest: Login successfully
Signature: FirstCest:loginSuccessfully
Test: tests\acceptance\FirstCest.php:loginSuccessfully
Scenario --
ERROR
------------------------------------------------------------------------------------------------------------------------
Time: 722 ms, Memory: 8.00 MB
There was 1 error:
---------
1) FirstCest: Login successfully
Test tests\acceptance\FirstCest.php:loginSuccessfully
[Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: 'unknown command: wd/hub/session'
#1 D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:298
#2 D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
#3 D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:212
#4 D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:44
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
I tried changing the chromedriver.exe to the installation path of chrome but it's still the same. I really don't know how to configure the url for chromedriver since it only came as an .exe.
This is my acceptance suite in codeception just in case:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://localhost/ASTechOLE/login.php'
window_size: false # disabled in ChromeDriver
port: 9515
browser: chrome
capabilities:
"goog:chromeOptions": # additional chrome options
- \Helper\Acceptance
Thanks in advance
Update:
I ran chromedriver with ./chromedriver --url-base=/wd/hub
Now it gives me
There was 1 error:
---------
1) FirstCest: Login successfully
Test tests\acceptance\FirstCest.php:loginSuccessfully
[Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: 'unhandled request'
#1 D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:298
#2 D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
#3 D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:212
#4 D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:44
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Based on your stacktrace, it seems that you are working in Windows.
Try running the chromedriver without leading trailing slash, wd/hub instead of /wd/hub.
Your command then becomes: ./chromedriver --url-base=wd/hub.
I know, Windows can be "fun" sometimes :)
Im trying to run API tests enabling Queue module in codeception.
Im running a project which consists on an api running on a vagrant machine, alpine-sqs is running on host:
http://localhost:9325/ web interface of alpine-sqs
http://localhost:9324/queue/default default alpine-sqs queue
I didnt modify default alpine-sqs config. And I have the following configuration in my codeception api suite:
class_name: ApiTester
modules:
enabled:
- Symfony:
app_path: src
environment: dev
- REST:
url: /api
depends: Symfony
- Queue
- \Helper\Api
- Asserts
config:
Queue:
'type': 'aws'
'endpoint': 'http://10.0.2.2:9324'
'version': '2012-11-05'
'region': 'eu-central-1'
When I run the following test:
<?php
$I->seeQueueExists('default');
$I->clearQueue('default');
$I->addMessageToQueue('this is a message', 'default');
$I->seeQueueHasCurrentCount('default', 1);
?>
It fails and the last step throwing the following:
1) CorrectCreationCest: Send valid creation request
Test tests/api/campaigns/create/CorrectCreationCest.php:sendValidCreationRequest
Fail Failed asserting that '0' matches expected 1.
Scenario Steps:
4. $I->seeQueueHasCurrentCount("default",1) at tests/api/campaigns/create/CorrectCreationCest.php:111
3. $I->addMessageToQueue("this is a message","default") at tests/api/campaigns/create/CorrectCreationCest.php:110
2. $I->clearQueue("default") at tests/api/campaigns/create/CorrectCreationCest.php:109
1. $I->seeQueueExists("default") at tests/api/campaigns/create/CorrectCreationCest.php:108
Somehow codeception achieves connecting to alpine-sqs and retrieves queues correctly but when checking message in queue fails, I dont know why.
Thanks
One of my application suddenly started to give error:
Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in /var/www/_slim/_core/system/generator.001.php:133 Stack trace: #0 /var/www/_slim/_core/system/generator.001.php(133): Redis->auth('77B1BFFBC0378DF...') #1 /var/www/_slim/_core/system/generator.007.php(144): Generator001->r6_redis_start('R') #2 /var/www/_slim/_core/system/generator.007.php(26): Generator007->HarvestRedis() #3 /var/www/_slim/_core/system/generator.shopping.php(14): Generator007->Generator007() #4 /var/www/_slim/_core/system/generator.last.php(43): Generator008->Generator008() #5 /var/www/_slim/site/home/php/index.php(16): GeneratorLast->GeneratorLast() #6 /var/www/index.php(96): Gui->Gui()
#7 {main} thrown in /var/www/_slim/_core/system/generator.001.php on line 133
I have reinstalled redis-server but no luck so far. Any suggestions?
Maybe not the answer to the specific question, but might help those new to Redis who come here by googling the Exception.
You will also get this exception if you create a Redis instance and start to call methods on it without first connecting to a Redis server by calling
$redis->connect('localhost')
The arguments for the call should obviously be adjusted if Redis is not a local host, configured to listen on a different port, set up a password etc.
Well, as the exception describes itself, your Redis server is down.
Try the following stuff:
See if the server that runs the Redis instance contains any firewall on (iptables, maybe?).
Go to your web server (that runs your php) and try to telnet to your redis server.
See if the configured host/ip is correct. Maybe something in the network settings of the Redis server have been changed.
I had a problem connecting to the redis
I managed to solve it by changing the colon to a comma
$redis->connect('localhost:6379');
from this to this
$redis->connect('localhost', 6379);
If you are running on a local/dev environment, make sure that Redis Service is running.
You can check if your local service is running by opening the Redis Client cmd. If you are on a MAC open the command line and type redis-cli.
If your server is running you should see:
redis 127.0.0.1:6379>
In my case I forgot to start the windows service so all I had to do was to: open services.msc, start Redis Server service.
I've had the same issue when integrating my software with local Redis installation. Turned out "localhost" host name was not resolved (stuff was was running in a docker container which didn't know that). Changed it to regular loopback IP "127.0.0.1" in the client config and it rolls.
My issue was that I was using Docker Compose and needed to use the name of the container instead of 'localhost'.
// Connect to the Redis Docker created server. 'redis' refers to the
// 'redis' container in the docker-compose.yml file.
$redis->connect('redis');
// docker-compose.yml
redis:
image: redis:alpine
volumes:
- redis-data:/data
ports:
- ${FORWARD_REDIS_PORT:-6379}:6379
healthcheck:
test: ["CMD", "redis-cli", "ping"]
networks:
- default
I'm running the latest version of Codeception on a vagrant box and I can't get either the acceptance or functional testing working.
Here's acceptance.suite.yml:
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser
- AcceptanceHelper
config:
PhpBrowser:
url: 'http://test.dev'
and my acceptance test:
$I = new AcceptanceTester($scenario);
$I->wantTo('check Codeception');
$I->amOnPage('/');
$I->see('hello');
The index page is a simple html output with 'hello world'
The error I'm getting is as follows:
1) Failed to check codeception in testTestCept (/vagrant/test/tests/acceptance/testTestCept.php)
Sorry, I couldn't am on page "http://test.dev/":
GuzzleHttp\Exception\RequestException: cURL error 6: Couldn't resolve host 'test.dev'
Scenario Steps:
1. I am on page "http://test.dev/"
#1 /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php:91
#2 /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/StreamingProxyAdapter.php:34
#3 /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Client.php:186
#4 /vagrant/fmx/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#5 /vagrant/fmx/tests/acceptance/AcceptanceTester.php:128
#6 /vagrant/fmx/tests/acceptance/testTestCept.php:5
#1 /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php:91
#2 /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/StreamingProxyAdapter.php:34
#3 /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Client.php:186
#4 /vagrant/fmx/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#5 /vagrant/fmx/tests/acceptance/AcceptanceTester.php:128
#6 /vagrant/fmx/tests/acceptance/testTestCept.php:5
My functional test is just as simple:
$I = new FunctionalTester($scenario);
$I->wantTo('check Codeception');
$I->amOnPage('/');
$I->see('hello');
With this one I get the following error:
There was 1 error:
---------
1) Failed to check codeception in testTestCept (/vagrant/test/tests/functional/testTestCept.php)
#1 /vagrant/test/tests/functional/testTestCept.php:5
#2 /vagrant/test/tests/functional/testTestCept.php:5
Line 5 is specifically: $I->amOnPage('/');
I'm new to vagrant so I'm not sure if I've missed something in the setup or if I've done something else wrong. I'm running codeception through vagrant ssh.
UPDATE:
We've got the Acceptance testing working. Now just focusing on the Functional testing. As requested, below is the complete functional.suite.yml content. As I'm setting up in stages, I've not actually modified this:
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# Include one of framework modules (Symfony2, Yii2, Laravel4) to use it.
class_name: FunctionalTester
modules:
enabled: [Filesystem, FunctionalHelper]
I had the same problem and this helped me:
unable to run codeception in virtual machine -Mink could not be found and loaded
I needed to add an entry in my /etc/hosts file for my site inside of my vm.
OSX machine running MAMP. CakePHP 2.2.1 installed and configured properly (meaning that I have all green bars when I browse to the Index.php file, I have completed the Blogs tutorial and am working on my second app with which scaffolding is up and running). Now I am trying to Bake for the first time.
Per the cookbook (and others), I installed a fresh copy of cake into a directory (my users directory) and then put the path variable in my .bash_profile file
export PATH="$PATH:/Users/p_scott/cake221/app/Console"
after which I was able to go into Terminal, type cake and have the console come up. You can see that up to that point, I was invoking the console from the app directory.
I first tried running cake bake from the terminal using the -app parameter and designating the path to my practice apps. The first time I did this, I got the following
Welcome to CakePHP v2.2.1 Console
-------------
App : app
Path: /Applications/MAMP/htdocs/blog/app/
-------------
Interactive Bake Shell
---------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
> c
--------------------
Bake Controller
Path: /Applications/MAMP/htdocs/blog/app/Controller/
--------------------
\Use Database Config: (default/test)
[default] >
No matter what I put in for the database (if I leave it blank, it asks me again), but any answer gives me the following error:
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/p_scott/cake221/lib/Cake/Model/Datasource/Database/Mysql.php, line 149]
Error: Database connection "SQLSTATE[HY000] [2002] No such file or directory" is missing, or could not be created.
#0 /Users/p_scott/cake221/lib/Cake/Model/Datasource/DboSource.php(260): Mysql->connect()
#1 /Users/p_scott/cake221/lib/Cake/Model/ConnectionManager.php(101): DboSource->__construct(Array)
#2 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ModelTask.php(906): ConnectionManager::getDataSource('default')
#3 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(396): ModelTask->getAllTables('default')
#4 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(419): ControllerTask->listAll(NULL)
#5 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(136): ControllerTask->getName()
#6 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(61): ControllerTask->_interactive()
#7 /Users/p_scott/cake221/lib/Cake/Console/Command/BakeShell.php(113): ControllerTask->execute()
#8 /Users/p_scott/cake221/lib/Cake/Console/Shell.php(393): BakeShell->main()
#9 /Users/p_scott/cake221/lib/Cake/Console/ShellDispatcher.php(201): Shell->runCommand(NULL, Array)
#10 /Users/p_scott/cake221/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch()
#11 /Users/p_scott/cake221/app/Console/cake.php(33): ShellDispatcher::run(Array)
#12 {main}
Once I started getting this error, I tried navigating in terminal to the <cake install dir>/app/Console folder and the <different instance of cake install dir>/app/Console folder to try the console from within my app/s. I either get the same errors or it asks me different questions, like:
What is the path to the project you want to bake?
[/Users/p_scott/myapp] > /Applications/MAMP/htdocs/history/app
What is the path to the directory layout you wish to copy?
[/Applications/MAMP/htdocs/history/lib/Cake/Console/Templates/skel] >
PHP CLI is installed and it appears to be working
PHP 5.3.8 (cli) (built: Dec 5 2011 21:24:09)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
My PDO support appears to be enabled. In terminal I typed:
php --ri pdo
PDO
PDO support => enabled
PDO drivers => mysql, sqlite, sqlite2
I don't have a php.ini file in Apache (because I am on a Mac), but the one in the PHP 5.36 directory, I have the following extensions enabled:
extension=imap.so
extension=yaz.so
extension=mcrypt.so
extension=gettext.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so
After taking a break, I found an article
(http://www.dereuromark.de/2011/10/31/freshly-baked-cake2-0-tips/) that talks about a change of console location in 2.0. I should try using it from that location (<cake installed dir>/lib/Cake/Console ). Once I tried this, I either got the questions about what layout I wanted to use or... ONCE, I was able to get the bake application to ask me to create a database configuration. I went through the steps and it pooped out this error at the end:
Fatal error: Class 'DATABASE_CONFIG' not found in /Applications/MAMP/htdocs/history/lib/Cake/Console/Command/Task/DbConfigTask.php on line 264
Which leads me to one more piece of info. This is my default DB configuration in the <cake installation dir>/history/app/Config/database.php file.
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'cakeHistoryUser',
'password' => 'cakeHistoryPassword',
'database' => 'cake_history',
'prefix' => '',
//'encoding' => 'utf8',
);
Before posting this question (and all of this information), I spend some quality time out here and it seems like most of my issues are or CLI related but I just don't see where I need to change something and hours and hours later, I need some help.
Help me Obi Wan, you are my only hope
The problem is you are trying to interact with the database via the command line, however the PHP-CLI is a different install than the one proveided by MAMP so it doesn't know about the database server.
Try changing localhost to 127.0.0.1 in your app/Config/database.php file and that should do the trick.
Something like this happened to me, and the easiest way I found to make it work which I don't see here is changing localhost to 127.0.0.1 and adding the port number at the end, e.g., MAMP uses port number 8899, so:
"mysql:host=127.0.0.1:8889"