In laravel 5.4, I can see that there are methods such as:
$browser->pause(1000);
$browser->waitFor('.selector');
$browser->waitForLink('Create');
But I don't see these in Laravel 5.3.
We have two chained select boxes where second select box values are loaded through ajax based on selection from first select box. The problem is that when we run test, laravel doesn't wait for second selectbox/ajax to load which makes the test fail because it could not select any value from second select box.
$this->visit('/department');
$this->select('1', 'country_id');
$this->select('1', 'region_id'); // problem here
// rest of code
I also tried using sleep() but it didn't work.
Any idea of how to functional test such scenario in 5.3 please ? Thanks
By default, laravel 5.3 doesn't support this function. As they have introduced Ajax Testing in laravel 5.4 using Dusk.
Check this post : https://laravel-news.com/laravel-dusk-is-coming
However, We are in luck.
Looking at the composer.json of dusk. You can use it in laravel 5.3 as its dependency is "illuminate/support" : "~5.3" which is satisfied by the Laravel 5.3.
All you need to do is : composer require laravel/dusk
Check the composer.json here : https://github.com/laravel/dusk/blob/master/composer.json
Edit:
There was an issue with the dependency. I created a new package which resolved the dependency issue. I have run all the test cases. It didn't give me any error.
You can use this package using following command : composer require pankitgami/dusk
Check here : https://packagist.org/packages/pankitgami/dusk
seeJsonEquals used for Verify Exact JSON Match
$this->post('/user', ['name' => 'Sally'])
->seeJsonEquals([
'created' => true,
]);
Related
Since last week I noticed problem on few places in the app I am working on. After investigation I found that with
composer require doctrine/orm 2.13.1
Everything is ok, but with:
composer require doctrine/orm 2.13.2
App brakes on places where I use enum in query like:
$builder->...->setParameter('type', Type::VARIANT) // Type is enum
I tried to read about it:
here and here but I do not see info about this.
Error is written in title.
Field is mapped via xml with
name="type" type="smallint" enum-type="Type". It is valid, worked for months.
Does anybody knows why doctrine support for enum does not work, or if not that what could cause this problem?
might be related to https://github.com/doctrine/orm/issues/10066 so i would say downgrade to 2.13.1 and wait for 2.13.4
I'm trying to build a small application on Laravel with modular approach, I am having a controller method which seeds the database as per the module/plugin name:
I have something like this:
Artisan::call('db:seed --class=Nitseditor\\Plugins\\'.$pluginName.'\\Databases\\seeds\\InstallSeeder');
Whenever I am calling this I am getting this error in my console.
Class NitseditorPluginsConfidenceDatabasesseedsInstallSeeder does not exist
I don't know why it remove \ and concatenate the strings.
How can I achieve this?
You can do:
$fullClassName = "Nitseditor\\Plugins\\${pluginName}\\Databases\\seeds\\InstallSeeder";
Artisan::call("db:seed", ['--class' => $class]);
in my case when i have some module in subfolders
then want to run one of the Seeders directly without running other seeders
php artisan db:seed --class=WM\Common\Seeder\SmsStatusSeeder
I'm using following:
PHP 7.2
MongoDB 3.4
Pecl 1.5.2
I'm working on a Laravel project. It uses MongoDB as database. I have few collections on which I have to create Mongo Views using Laravel migration. I was wondering whether its possible to create Mongodb Views using PHP. Currently I have a work around. I have created a JavaScript file which has MongoDB db.createView() query in it. It also takes view name and collection name as parameters. Following is my work around. $db has database name, $view has view name, $collection has collection name and $script has the path to the JavaScript file. This code I'm writing in migration class's up() method.
$cmd = "mongo $db --eval \"var view='$view', collection='$collection'\" $script";
exec($cmd);
In my Javascript file, I have code something like following
db.createView(view, collection, <aggregate query>);
So as everyone can see, I'm running terminal command from PHP to make views. So is there any PHP function in mongo library to make mongo views?
If you're using mongo with Laravel, I'm going to assume you're using jenssegers/mongodb to use it with Eloquent.
So, let's assume you have your mongo database set up as your 'mongodb' database connection. You need the MongoDB\Database for your database. You can get this with:
$mongo = app('db')->connection('mongodb')->getMongoDB();
Of course, if you're not using jenssegers/mongodb, you can still do the same thing with mongodb/mongodb as well.
$mongo = (new MongoDB\Client)->selectDatabase($db);
This has a method called command (see https://docs.mongodb.com/php-library/current/reference/method/MongoDBDatabase-command/), which corresponds to the db.runCommand method from the mongo cli. db.createView calls that method (see https://docs.mongodb.com/manual/reference/method/db.createView/#db.createView)
So, you can use $mongo->command to create the view like this:
$mongo->command([
'create' => $view,
'viewOn' => $collection,
'pipeline' => $aggregateQuery,
'collation' => ['locale' => 'en'],
]);
You can use this library mongoPhpLibrary
This will make your work easy
I change with cakephp 3.2 to a new server and this server is running php 7 instead of 5.4. Now I have an issue with my interactive way of calling an component and the needed action. What I was using is the following:
$data[$csvKnowField->field_number] = $this->Replace->$csvKnowField['imports_mapping']['component_action']($data[$csvKnowField->field_number]);
This is giving the error: Function name must be a string. As far as I can see the problem is coming from the action called because if I change it to:
$data[$csvKnowField->field_number] = $this->Replace->replaceComma($data[$csvKnowField->field_number]);
everything works fine. The variable $csvKnowField['imports_mapping']['component_action'] is holding an interactive value so the different actions can be called in the Replace component, so it would be great to keep it that way.
Is there somebody how knows an solution so the the value in the variable can be used as an interactive way?
I'm attempting to implement https://github.com/PHP-FFMpeg/PHP-FFMpeg
I copied the src/FFMpeg folder to my includes folder and made sure my autoloader knows where to find everything.
as a test I made a script that simply does:
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
I get:
Fatal error: Class 'Doctrine\Common\Cache\ArrayCache' not found in /var/www/php/include/FFMpeg/FFProbe.php on line 203
My question is: does PHP-FFMPeg require Doctrine, because that is not stated in the documentation. What version do I need? Are there other prerequisites?
I could create a new question for this, but I'm not sure if I should. I now have PHP-ffmpeg implemented. I'm using Laravel, however that should be irrelevant for this question. I'm trying to enable progress monitoring. It works, however I need to pass in an ID so I can update the correct key in memcache.
$id = 12345;
$format->on('progress', function ($audio, $format, $percentage) {
//this works perfect, but doesn't tell me which item is being updated
Cache::put("progress", $percentage, .25);
//this does not work as I am unable to pass in $id, if I add it as the 4th argument above it will display the number of threads or something
//Cache::put("{$id}_progress", $percentage, .25);
});
I need clarification on the "on" method. I looked through https://ffmpeg-php.readthedocs.org/en/latest/_static/API/ and was not able to figure out how this method works. Any help would be appreciated.
You should follow the recommended instructions in the README.
Composer is the easiest way to install PHP-FFMpeg dependencies
The "on" method called on the format is an implementation of EventEmitter.
As you can see here : https://ffmpeg-php.readthedocs.org/en/latest/_static/API/FFMpeg/Format/ProgressableInterface.html it extends the EventEmitterInterface of https://github.com/igorw/evenement.
If you're really interested about how it works under the hood, have a look at here :
The progress listener is created here : https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Format/Audio/DefaultAudio.php#L96 and added at execution here https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Media/Video.php#L151
This is actually possible because FFMpegDriver extends the Driver provided by https://github.com/alchemy-fr/BinaryDriver
Hope this helps :)