Install WordPress and plugins with Composer

MacBook avec code sur un bureau

Installing WordPress via Composer has often been difficult, fortunately there is now a solution! WordPress On GitHub there is a project that is updated every 15 minutes with the latest version of WordPress. It is also the most used. https://github.com/johnpbloch/wordpress In the composer.json just indicate the project name. In this example, we can also indicate … Read more

Git doesn’t fetch all branches in remote

MacBook Pro affichant un éditeur de code

Sometimes when you work with git, you don’t find all the remote branches. Even after using git fetch they do not appear. fetch git it is very likely that the origin of the fetch is wrong. We can see, for example, that here only the master branch is updated. $ git config –get remote.origin.fetch ‘refs/heads/master:refs/remotes/origin/master … Read more

PhpUnit – mock – internal set protected / private variable

MacBook avec code sur un bureau

Using mocks it is often necessary to give a value to a private or protected variable. To do this, just use the Reflection class. $basket – $this–getMockBuilder ('Basket') OriginalConstructor() -getMock(; $basketReflection – new ReflectionClass ($basket); $sessionId – $basketReflection–getProperty ('sessionId'); $sessionId-setAccessible (true); $sessionId-setValue ($basket, 'abc'); so the sessionId value in our Mock will be ‘abc’.

Yii: Create a personalized relationship between two tables

MacBook avec code sur un bureau

To make a custom relationship between two tables in a model, it is possible to add an additional option in the relation in which one indicates which foreign key should be used with which field. public function relations () { return array ( ‘NameRelation’ – array ( self::HAS_ONE, ‘otherTable, ”, ‘on”fk_otherTabletable.fk_otherTable ‘ otherTable.id’ ), ); … Read more

PHPUnit how to mocker / simulate an object and methods

Code sur écran d'ordinateur

When you start using PHPUnit, you often find yourself facing the need to simulate a method or object. Fortunately PHPUnit has some methods that can be very useful. How to simulate an object The easiest way to create a mocked object $product – $this–getMockBuilder (‘Product’) -getMock(; or $product – $this–getMockBuilder (‘Product’) -setMethods (array)) -getMock(; This … Read more