sebastianknott/dev-utils

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

This is a collection of stuff I need for developing.

This package is auto-updated.

Last update: 2021-11-08 14:25:34 UTC


README

... or in short DUSK (Yeah. That's how I roll) is a tool set for my personal development projects. It helps me get things of the ground rather quick and keeps things hassle free and automated. I try to keep things civil, so it SHOULD work with php >= 7.2, but I will focus on running up-to-date versions of PHP.

Whats included?

Here comes a short list of stuff you can find here.

Unit Tests Tools

For UnitTest I personally prefer the obvious.

DevUtilsTestCase

I included a new base class for unit tests called DevUtilsTestCase. This class will have an instance of faker and my personal SystemUnderTestFactory. Additionally the global functions of mockery and hamcrest are accessible in your test class.

<?php

use Mockery\MockInterface;
use SebastianKnott\DevUtils\Test\Infrastructure\DevToolsTestCase;

class ExampleTest extends DevToolsTestCase
{
   public function testExample(){
       // Build your subject with mocked dependencies. There is
       // also a method for all you phake fans out there ^^
       $subjectBundle = self::$factory
           ->buildSutWithMockery(Example::class);

       // Access your subject by getting it from the bundle.
       $subject = $subjectBundle->getSubject();

       // Access the corresponding mocked constructor parameters
       // by name with array notation.
       /** @var MockInterface $firstParameter */
       $firstParameter = $subjectBundle['firstParameterName'];

       // Notice that you can access hamcrest functions globally
       // (e.g. `startsWith`)
       $firstParameter->shouldReceive('myTest')
           ->with(startsWith('bla'));

       // ... and faker stands by for your disposal
       $result = $subject->runMyStuff(self::$faker->address);

       assertThat($result, is(boolValue()));
   }
}

Deployer

I wrote two rather unusual recipes for deployer.

Recipe staticCodeAnalysis

This recipe contains targets for the tools found under Code Quality Tools.

dep <command> What it does
sca Static Code Analysis - runs all sca commands in order
sca:lint Check for syntax errors
sca:phpcpd Check for copy/paste violations
sca:phpcs Runs Code Sniffer with my coding-standard
sca:phpcs:fix Runs Code Sniffer in fix mode
sca:phpmd Check for messy code
sca:phpstan Check for messy code with phpstan
sca:psalm Check for messy code with vimeos psalm

Recipe unitTest

This recipe contains targets for phpunit and infection to run efficiently.

dep <command> What it does
test:infection Runs infections for phpunit. Has a dependency on test:phpunit
test:phpunit Runs phpunit tests

Composer Libraries I like

There is a list of tools I really love and install sooner or later anyway.

Code Quality Tools

All the tools I need with configurations compatible to each other.

For now everything is just a scaffold for things to come. Everything is stitched together by deployer. A simple dep sca should execute all tools.

Included with phpcs comes my own coding-standard. A pretty mellow mix between slevomats coding-standard and PSR-12.