2017 © Pedro Peláez
 

library phpunit-test-generator

Generates tests for use with PHPunit based on an existing composer.json

image

idrinth/phpunit-test-generator

Generates tests for use with PHPunit based on an existing composer.json

  • Tuesday, July 24, 2018
  • by Idrinth
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 11 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Test-Generator for PHPUnit

Codacy Badge Codacy Badge Build Status CodeFactor BCH compliance, (*1)

Command & Options

php bin/generate-tests --dir=/path/to/alternative/dir --mode=replace

dir

Dir is optional and will default to the current working directory. Pick the directory that the composer.json is in., (*2)

replace (deprecated, see mode)

If set old testfiles will be overwritten, if not set they will be renamed instead. Usually you shouldn't need this., (*3)

mode

One of replace, skip or move. Defines how to handle file conflicts and defaults to moving the old file., (*4)

output

If set will be prepended to the relative paths of dev-autoload paths., (*5)

How does it work?

The composer.json at the working directory(or the supplied dir) will pe parsed for namespaces(psr 0 and 4), the folders targeted by none-dev namespaces will be searched for classes and test classes will be generated in the appropriate development-autoloading-folder. To determine the testing class to be used, the phpunit dev-dependency is parsed, so you need to supply a constraint to make the generation work., (*6)

Generated Test - Example

This is a generated testfile for the actual Controller of this library. The intention is to generate PSR2-compatible code, obviously that might not yet be the case everywhere. If you find one where it fails, feel free to file a bug., (*7)

<?php

namespace De\Idrinth\TestGenerator\Test;

use PHPUnit\Framework\TestCase as TestCaseImplementation;
use De\Idrinth\TestGenerator\Controller;

/**
 * this is an automatically generated skeleton for testing Controller
 * @todo actually test
 **/
class ControllerTest extends TestCaseImplementation
{
    /**
     * @return Controller
     * @todo make sure the construction works as expected
     **/
    protected function getInstance()
    {
        return new Controller(
            $this->getMockBuilder('Symfony\Component\Finder\Finder')->getMock(),
            $this->getMockBuilder('De\Idrinth\TestGenerator\Interfaces\ClassReader')->getMock(),
            $this->getMockBuilder('De\Idrinth\TestGenerator\Interfaces\ClassWriter')->getMock(),
            $this->getMockBuilder('De\Idrinth\TestGenerator\Interfaces\Composer')->getMock(),
            null
        );
    }

    /**
     * From Controller
     * @test
     * @todo replace with actual tests
     **/
    public function testInit ()
    {
        $instance = $this->getInstance();
        $return = $instance->init();

        $this->assertInternalType(
            'object',
            $return,
            'Return didn\'t match expected type object'
        );

        $this->assertInstanceOf(
            'De\Idrinth\TestGenerator\Controller',
            $return,
            'Return didn\'t match expected instance De\Idrinth\TestGenerator\Controller'
        );

        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }

    /**
     * From Controller
     * @test
     * @todo replace with actual tests
     **/
    public function testRun ()
    {
        $instance = $this->getInstance();
        $return = $instance->run();

        $this->assertInternalType(
            'null',
            $return,
            'Return didn\'t match expected type null'
        );

        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }
}

The Versions

24/07 2018

dev-fix-static-anaylsers

dev-fix-static-anaylsers https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

21/07 2018

dev-master

9999999-dev https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

05/05 2018

dev-handle-static-methods

dev-handle-static-methods https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

29/04 2018

dev-more-modes-for-writing

dev-more-modes-for-writing https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

08/04 2018

dev-symfony/console_bsp_class

dev-symfony/console_bsp_class https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

08/04 2018

dev-symfony/console

dev-symfony/console https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

23/03 2018

dev-namespace-resolution

dev-namespace-resolution https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest

23/03 2018

dev-add-composer-version-parsing

dev-add-composer-version-parsing https://github.com/Idrinth/phpunit-test-generator/

Generates tests for use with PHPunit based on an existing composer.json

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit generator unittest