(Linux) vagrant ssh -c "hostname -I | cut -d' ' -f2" 2>/dev/null
(OS X) vagrant ssh -c "hostname -I | cut -d' ' -f2" 2>/dev/null | pbcopy ?>
Mix Prophecy Mock Framework with PHPUnit Mock Builder to Create Mocks for Not Existing Classes and Magic Methods
Prophecy is great as long as you are creating mocks for classes or methods, which are existing in your code base. The benefit is, that the usage is a bit more convenient compared with the PHPUnit mock builder (e.g. method definition and parameter handling). Therefor Prophecy is integrated into PHPUnit by default.
If you want to create mocks for classes, which are not existing in your code base or if you want to mock magic methods, this will become a problem. You could create a real class, just to have the class/method. But this is not an nice solution. That's why mixing mocking functionality from the Prophecy mocking framework and the PHPUnit mocking framework makes sense.
Here I am not questioning, if it is good to create tests for classes, that do not belong to your code base. I am just showing a way to handle this.
The following example works with PHPUnit 4.8.35 and up. The Prophecy mocking framework is part of PHPUnit.
// Mock the object via Prophecy - generally more convenient than with PHPUnit itself
$entityManager = $this->prophesize(EntityManager::class);
// Create the mock object by PHPUnit, for a class that does not exist.
$shippingMethodRepository = $this->getMockBuilder('ShippingMethod')
// Set the not existing method.
// Define that getRepository() can retrieve any arguments and get a "real" object to test with.
// Mock a few methods with Prophecy as you like
// Get the mocked object, which will fake behavior
// Will return 'Hermes'
Selecting data from one table with multiple conditions with Subselects is slow. Joins are quicker. Here is an example:
select * from OrderMetaData
Join OrderMetaData as a on OrderMetaData.id = a.Order_id and a.name = 'store' and a.value = 128
Join OrderMetaData as b on OrderMetaData.id = b.Order_id and b.name = 'processing_status' and b.value = 4;
This query takes 0,44 seconds in a table with > 800.000 entries. The sub-select takes 17 seconds.
There are many approaches and often they are tricky. The simplest approach is the following and it does not need any additional wrapper-elements. Just place the CSS inside the selector, which is containing your content. The content will be positioned in the horizontal and vertical middle of the container. Mind that the Flexbox CSS feature is fully supported since IE 11.
rsync -acve ssh --dry-run USER@SERVER:/home/some-domain/ .
This Rsync command will compare files and folders via checksums. If any file has changed, it will be listed. The command will list folders in any case. This does not point to any change. Mind the listed files.
I prefer using XDebug for debugging PHP code. But sometimes there's a huge nesting in the project, which makes the application very slow. Then XDebug can become pain. So there's an alternative for inspecting the contents of objects:
It works for single objects and Doctrine collections and should prevent browser displaying issues you are having.
The best tool for debugging eMails locally in my opinion is Mailcatcher. It catches all mails being sent via a specific port and shows them to you via an neat interface in your webbrowser. Firstly install Mailcatcher. It's programmed in Ruby and I could install it easily on Ubuntu and Mac. The instructions can be found at https://mailcatcher.me/.
In the full stack edition it comes with symfony/swiftmailer-bundle. Make sure these settings are in your parameters.yml + parameters.yml.dist file.
Afterwards you can send a test mail via the console:
The mails will be shown to you like in the screenshot below.
Beside Drupal 8 install the "SMTP Authentication Support". You can find it's project webpage at https://www.drupal.org/project/smtp. Then visit the following page in your Drupal 8 instance: http://your-neat-webpage.dev/admin/config/system/smtp. Make sure the following settings are set in the config form (there's also a possibility to set them in the settings.php file).
SMTP server: 127.0.0.1
SMTP backup server: LEAVE BLANK
SMTP port: 1025
Use encrypted protocol: No
SMTP AUTHENTICATION: LEAVE USERNAME + PASSWORD BLANK
E-MAIL OPTIONS: ANY EMAIL AND FROM NAME
SEND TEST E-MAIL: ANY E-MAIL ADDRESS
Check "Enable debugging".
<?php $queryBuilder = $this->entityManager->createQueryBuilder()
$queryBuilder->where('mbt INSTANCE OF Bundle:SomeType');
HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX /path/to/source/images/dir
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX /path/to/source/images/dir