phpunit / Symfony: BadMethodCallException - php

I want to test the http status code of URLs from my project.
By some tests I got the following error message from phpunit:
1) pp\TheBundle\Tests\UrlTests\UrlTests::test18Url
PHPUnit_Framework_Exception: PHP Fatal error: Uncaught exception 'BadMethodCallException' with message 'A Crawler cannot be serialized.' in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:315
Stack trace:
#0 [internal function]: Symfony\Component\DomCrawler\Crawler->serialize()
#1 -(364): serialize(Array)
#2 -(513): __phpunit_run_isolated_test()
#3 {main}
thrown in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php on line 315
Fatal error: Uncaught exception 'BadMethodCallException' with message 'A Crawler cannot be serialized.' in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php on line 315
BadMethodCallException: A Crawler cannot be serialized. in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php on line 315
Call Stack:
0.0022 441400 1. {main}() -:0
0.0400 4434840 2. __phpunit_run_isolated_test() -:513
0.6232 30949432 3. serialize() -:364
0.6235 31024280 4. Symfony\Component\DomCrawler\Crawler->serialize() -:364
This is the content of the test function:
$crawler = $this->helper->getCrawler('/de/profil/the-profile/123/veroeffentlichen', [
'user' => $this->helper->getParameter('testing')['user']['admin']['username'],
'pwd' => $this->helper->getParameter('testing')['user']['admin']['password'],
]);
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode(),
'Status-Code ' . $this->client->getResponse()->getStatusCode() . ' on URL ' . $this->client->getRequest()->getUri() . '');
Any ideas, why this error happens? The debugging informations from phpunit are not really helpfull...

It's a strange solution, but it worked in my problem. Please, change assertEquals to assertContains.

Change config processIsolation to false, you should get a more clear test failed message

Related

Detectlanguage - Fatal Error Uncaught Exception

I try to use this github library
https://github.com/detectlanguage/detectlanguage-php
I signed up for an API Key before.
My code is very simple, but throws an uncaught expection immediately:
require_once 'includes/detectlanguage/lib/detectlanguage.php';
use \DetectLanguage\DetectLanguage;
DetectLanguage::setApiKey("xxxxxxx7687af9cb91950327ea");
$languageCode = DetectLanguage::simpleDetect("Hallo und einen schönen Tag");
Fatal error: Uncaught exception 'DetectLanguage\Error' with message 'Invalid server response: ' in /var/www/bodo/dokumente-online.com/includes/detectlanguage/lib/DetectLanguage/Client.php:45 Stack trace: #0 /var/www/bodo/dokumente-online.com/includes/detectlanguage/lib/DetectLanguage/DetectLanguage.php(80): DetectLanguage\Client::request('detect', Array) #1 /var/www/bodo/dokumente-online.com/test_detect.php(7): DetectLanguage\DetectLanguage::detect('HAllo und einen...') #2 {main} thrown in /var/www/xyz.com/includes/detectlanguage/lib/DetectLanguage/Client.php on line 45
Any idea what I am doing wrong?
Service seems to work.

Laravel 5.1 illuminate/queue capsule error 'Class encrypter does not exist'

I have the need to push jobs on a queue from outside the Laravel framework. Found the queue capsule manager that should make this possible:
https://github.com/illuminate/queue
Trying the following as per their example code:
<?php
require_once __DIR__ . '/../../bootstrap/autoload.php';
use Illuminate\Queue\Capsule\Manager as Queue;
$queue = new Queue;
$queue->addConnection([
'driver' => 'sync',
]);
$queue->setAsGlobal();
$queue->push(function($job)
{
echo "test!\n";
$job->delete();
});
Running this code results in the following error:
PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class encrypter does not exist' in vendor/laravel/framework/src/Illuminate/Container/Container.php:741
Stack trace:
#0 vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass->__construct('encrypter')
#1 vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('encrypter', Array)
#2 vendor/laravel/framework/src/Illuminate/Container/Container.php(1163): Illuminate\Container\Container->make('encrypter')
#3 vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php(117): Illuminate\Container\Container->offsetGet('encrypter')
#4 vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php(135): Illuminate\Queue\QueueM in vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741
Fatal error: Uncaught exception 'ReflectionException' with message 'Class encrypter does not exist' in vendor/laravel/framework/src/Illuminate/Container/Container.php:741
Stack trace:
#0 vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass->__construct('encrypter')
#1 vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('encrypter', Array)
#2 vendor/laravel/framework/src/Illuminate/Container/Container.php(1163): Illuminate\Container\Container->make('encrypter')
#3 vendor/laravel/framework/src/Illuminate/Queue/QueueManager.php(117): Illuminate\Container\Container->offsetGet('encrypter')
#4 vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php(135): Illuminate\Queue\QueueM in vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741
Searching on this subject I found something that said to add the following code:
$queue->getContainer()->bind('encrypter', function() {
return new Illuminate\Encryption\Encrypter('nInrMfTMQngxqRvoFpjstYjZX0qH1Nlr', 'AES-256-CBC');
});
$queue->getContainer()->bind('request', function() {
return new Illuminate\Http\Request();
});
Which does not seem to be a solution, because I then get the following error:
PHP Fatal error: Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Encryption\Encrypter] is not instantiable.' in vendor/laravel/framework/src/Illuminate/Container/Container.php:749
Stack trace:
#0 vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Container\Container->make('Illuminate\\Cont...')
#2 vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#3 vendor/laravel/framework/src/Illuminate/Container/Container.php(776): Illuminate\Container\Container->getDependencies(Array, Array)
#4 in vendor/laravel/framework/src/Illuminate/Container/Container.php on line 749
Binding those should not be needed though, judging by the documentation from illuminate/queue.
This occurs with laravel 5.1.27. Any thoughts/solutions?
Update: I have tried it in a 4.2 environment, there I also have to bind the encrypter class, but doing that there works. (Does not give the not instantiable error)
After playing around a bit you should add one more binding, after the encrypter binding, to get around this issue.
$queue->getContainer()->bind('Illuminate\Contracts\Encryption\Encrypter', 'encrypter');
Binding the encrypter to the contract.

Wordpress plugin fatal error

I downloaded this taxi booking plugin from Github but when I try to activate it on wordpress I get a fatal error and it doesn't let me activate it. You can find the plugin on https://github.com/mbejda/TaxiCabBookingSystem
Fatal error: Uncaught exception 'Braintree_Exception_Configuration' with message 'merchantIdneeds to be set' in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php:117 Stack trace: #0 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(139): Braintree_Configuration::get('merchantId') #1 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(157): Braintree_Configuration::setOrGet('merchantId', NULL) #2 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/modules/BookingSystemBrainTreeModule.php(32): Braintree_Configuration::merchantId(NULL) #3 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/main.php(177): BookingSystemBrainTreeModule->__construct(Object(BookingSystem)) #4 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-maste in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php on line 117
Any help to get this resolved would be appreciated.
UPDATE at Sunday 8th Feb # 8:18pm.
I have added the Merchant ID on Configuration.php its giving me the same error I think, if not the same then very simular
Fatal error: Uncaught exception 'Braintree_Exception_Configuration' with message 'publicKeyneeds to be set' in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php:117 Stack trace: #0 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(139): Braintree_Configuration::get('publicKey') #1 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php(162): Braintree_Configuration::setOrGet('publicKey', NULL) #2 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/modules/BookingSystemBrainTreeModule.php(33): Braintree_Configuration::publicKey(NULL) #3 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/main.php(177): BookingSystemBrainTreeModule->__construct(Object(BookingSystem)) #4 /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/ma in /Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php on line 117
Regards
Did you read the error message output... it says
Message 'merchantId needs to be set' in
/Applications/MAMP/htdocs/DocklandsTaxi/wp-content/plugins/TaxiCabBookingSystem-master/lib/Braintree/Configuration.php
[Update]
Also check out https://www.braintreepayments.com/docs/php

Create subdomain by cpanel api

I register on youhosting.com and use domain that registered on godaddy.com. I want to create new subdomain by programming. I have already see the tutorial on cPanel Documentation 1 and Doc 2
After I implement it, it show errors :
Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "couldn't connect to host" for https://bodoamat.com:2087/xml-api/listips?' in /home/u937182156/public_html/xmlapi.php:748 Stack trace: #0 /home/u937182156/public_html/xmlapi.php(666): xmlapi->curl_query('https://bodoama...', '', 'Authorization: ...') #1 /home/u937182156/public_html/xmlapi.php(2055): xmlapi->xmlapi_query('listips') #2 /home/u937182156/public_html/listips_example.php(44): xmlapi->listips() #3 {main} thrown in /home/u937182156/public_html/xmlapi.php on line 748
include 'xmlapi.php';
$ip='127.0.0.1';
$root_pass='mypassword';
$xmlapi = new xmlapi($host);
$xmlapi->set_port(2082);
$xmlapi->password_auth($my_user, $my_pass);
$xmlapi->set_debug(1);
print $xmlapi->api1_query($account, "Subdomain", "addsubdomain", array('user123', 'bodoamat.com'));
Any one may help me?
Thanks before
$xmlapi->api1_query($cpanelusr, 'SubDomain', 'addsubdomain', array('user123','bodoamat.com',0,0, '/public_html/directory_name'))

How to solve "Uncaught exception 'google\net\ProtocolBufferEncodeError'"

I'm using Google App Engine in combination with PHP.
After a couple request I get the following error
Fatal error: Uncaught exception 'google\net\ProtocolBufferEncodeError' with message 'Internal bug: Encoded size doesn't match predicted' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php:68
Stack trace:
#0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php(50): google\net\ProtocolMessage->serializePartialToString()
#1 /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php(52): google\net\ProtocolMessage->serializeToString()
#2 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(42): google\appengine\runtime\RealApiProxy->makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse), NULL)
#3 /base/data/home/runtimes/php/sdk/google/appengine/api/taskqueue/PushQueue.php(195): google\appengine\runtime\ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php on line 68
Fatal error: Uncaught exception 'google\net\ProtocolBufferEncodeError' with message 'Internal bug: Encoded size doesn't match predicted' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php:68
Stack trace:
#0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php(50): google\net\ProtocolMessage->serializePartialToString()
#1 /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php(52): google\net\ProtocolMessage->serializeToString()
#2 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(42): google\appengine\runtime\RealApiProxy->makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse), NULL)
#3 /base/data/home/runtimes/php/sdk/google/appengine/api/taskqueue/PushQueue.php(195): google\appengine\runtime\ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', Object(google\appengine\TaskQueueBulkAddRequest), Object(google\appengine\TaskQueueBulkAddResponse in /base/data/home/runtimes/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php on line 68
To solve this I shutdown all the instances and the code just loads normally. And again after a couple of request I get the same fatal error.
What can cause this Fatal error ? And how do I solve it.
The error is raised in the following file
https://chromium.googlesource.com/external/googleappengine/python/+/4523f63814037ed833b8bb55273c09a43dd69fb0/php/sdk/google/appengine/runtime/proto/ProtocolMessage.php

Categories