GithubHelp home page GithubHelp logo

katawcs's Introduction

kataStarter

##Empty kata and documentation how to set up a folder for a kata project

PHPUnit must be installed on your system before to run this process.

Just run :sudo apt install phpunit

  1. Create folders
mkdir kataExemple
cd kataExemple
mkdir tests     // unit tests
mkdir src       // source code
  1. Initialise composer
composer init
  • fill out package name and author, default value for other fields
  • dependencies (require) : no
  • dependencies (require-dev) : yes
  • package : phpunit
  • select phpunit/phpunit into the list (index 0 in most case)
  • version : leave blank for the lasted version
  • no other package
  • confirm generation : yes
  1. Install dependencies
composer install
  1. Set up autoloader : add following code to composer.json
"autoload": {
  "psr-4": {
    "wcs\\": "src/"
  }
}

change 'wcs' with your specific namespace

  1. Update autoloader
composer dump-autoload
  1. Create your first php file in src folder : KataExemple.php
<?php
  
  namespace wcs; // or your own namespace
  
  class KataExemple
  {
      public static function action($value)
      {
        ...
      }
  }
  ```
7. Create your first phpunit file in tests folder : KataExempleTest.php
<?php

class KataExempleTest extends PHPUnit_Framework_TestCase
{
    public function testAction()
    {
      $this->assertEquals(true, \wcs\KataExemple::action("value"));
    }
}
8. Create phpunit configuration file in your kataExemple folder : phpunit.xml

<phpunit colors="true" bootstrap="./vendor/autoload.php">
  <testsuite name="kata exemple testing">
    <directory>./tests</directory>
  </testsuite>
</phpunit>
9. Test your code 

./vendor/bin/phpunit


10. Correct your bug ;-)

##Optionnal : configure phpstorm to run phpunit tests

1. File/settings/Plugins: Check and add if necessary phpunit plugin (code coverage and autocomplete assistant)
2. File/settings/PHP/PHPUnit:
- check "use custom autoloader"
- path to script : the autoload.php to the vendor directory (.../kataExemple/vendor/autoload.php)
- check default configuration file : the phpunit.xml in your kataExemple directory
3. Create a new run/debug configuration
- Select PHPUnit
- Create a name
- select directory
- set path to your tests directory (.../kataExemple/tests)
- OK
4. You can run (or debug if xdebug is configured) your unit tests

katawcs's People

Contributors

2binfree avatar

Stargazers

Symfomany avatar

Watchers

James Cloos avatar Alexandre Fradet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.