Skip to content

Instantly share code, notes, and snippets.

@netraagal
netraagal / script.sh
Created April 12, 2021 08:15
Rename git branch
git checkout <old_name>
git branch -m <new_name>
git push origin -u <new_name>
git push origin --delete <old_name>
@netraagal
netraagal / EditFormType.php
Created September 25, 2020 09:09
Symfony form - Radio button in list view
<?php
namespace App\UserBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class EditFormType extends AbstractType
{
@netraagal
netraagal / 0_Add_a_command_line.md
Last active May 2, 2018 09:13
Symfony, Behat, add a Command Line

Add a Command Line to your Behat Project

As said, I want to add a command to my Behat Project.

I will add a '--list-scenarios' option to my behat command

Not so good

The files I add or modify are in my vendor project, so I'm actually in search of how to not use the vendor directory.

@netraagal
netraagal / README.md
Last active March 16, 2018 15:45
Symfony, Behat, MinkExtension & Selenium2 Driver - installation

Selenium2 driver with Behat & MinkExtension in a Symfony project

In the MinkExtension, there is differents drivers (more here).

Each one have it's caracteristics.

Generally, the Goutte driver is used to run, but there is more and more websites which have Js to be more interactive.

Goutte driver cannot run JS (it only get the page with it's raw text and do what you want it to do).

@netraagal
netraagal / 0_Traits_in_Php.md
Last active April 9, 2018 08:49
Behat, MinkExtension - order your functions

Use of Traits in Php

Here, traits allows to order the functions according to the categories you choose (as for me, what they do).

Even if you don't have many of functions, it's became really usefull (+gain of time) at the end. Because, after a little while, it can be really annoying to scroll beetwing functions.

And it appears more clean to have functions disposed and sorted in files.

@netraagal
netraagal / TimerFeatureContext.php
Last active March 16, 2018 15:48
Behat, MinkExtension & Selenium2 Driver - functions to wait
<?php
/**
* some functions to make a pause (minutes, seconds or milliseconds)
* The last one is a little more tricky as she will stop the Scenario to wait for the end of the loading of the
* scripts behind (you must be cautious if a script is created to run all the time)
*
* @author netraagal
*/
namespace App\Features;
use Behat\Mink\Driver\Selenium2Driver;
@netraagal
netraagal / AssertFeatureContext.php
Last active March 16, 2018 15:35
Behat, MinkExtension & Selenium2 Driver - asserts on form elements
<?php
/**
* All of those functions can be used to verify the validity of what is on the page
*
* @author netraagal
*/
namespace App\Features;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Element\NodeElement;
use \Exception;
@netraagal
netraagal / GetElementFeatureContext.php
Last active March 16, 2018 15:34
Behat, MinkExtension & Selenium2 Driver - select a NodeElement
<?php
/**
* those functions allos me to use only 1 Step definitio to get an element, even if I don't use the same
* parameters to get it.
* You can search with:
* - the xpath (Which can be really tricky sometimes)
* - an attribute of the element : id (the best) or name or value
* - the css (the more used)
* I pass the type of element and the element above but you can only use css and xpath (as the attributes
* can also be used on the css)
@netraagal
netraagal / WindowFeatureContext.php
Last active October 22, 2022 17:56
Behat, MinkExtension & Selenium2 Driver - move, create, delete window or tab (depends on your configurations)
<?php
/**
* some functions to create a new tab/window (it's up to your personal settings),
* to move between them (to the right, to the left or by it's number in the list of windows.
* You can also close the current window or close all (the first window will be open as if you
* close it, the Scenario will fails).
*
* I block the actual driver is not an instance of Selenium2 driver, but I don't really remember
* if it's an obligation :)
*