Code Monkey home page Code Monkey logo

php-tricorder's Introduction

PHP-Tricorder logo

(Logo generously created by Jacques Woodcock)

PHP-Tricorder is a CLI utility that scans structure files created using phpDocumentor and offers suggestions on potential problems with your code along with testing strategy information.

Executing '/path/to/php tricorder.php' will give you some usage information.

Please read the file LICENSE included with this code for licensing details.

How To Use It

  • Install phpDocumentor using your preferred method
  • Use docblocks to describe the parameters and return types for your methods
  • To generate a structure.xml document for an entire directory recursively, use 'phpdoc parse -d . -t'
  • To generate a structure.xml document for a specific file, use 'phpdoc parse -f /path/to.file -t'
  • Process the structure.xml document using tricorder: '/path/to/php tricorder.php /path/to/structure.xml'

Tricorder will then give you some suggestions on things to look for when testing your classes. Here's some sample output:

chartjes@php-vm:~/php-tricorder$ php tricorder.php ../building-testable-applications/lib/IBL/structure.xml 
Reading in phpDocumentor structure file...

FranchiseMapper.php

Scanning FranchiseMapper

__construct -- mock $conn as \PDO

createFranchiseFromRow -- test $row using an empty array()

delete -- mock $franchise as \IBL\Franchise

findAll -- test method returns \IBL\Franchise instances
findByConference -- test $conference using null or empty strings

findByConferenceDivision -- test $conference using null or empty strings

findByNickname -- test $nickname using null or empty strings

findById -- test $id using non-integer values

generateMap -- test $teamsTable using null or empty strings

save -- mock $franchise as \IBL\Franchise

_insert -- non-public methods are difficult to test in isolation
_insert -- mock $franchise as \IBL\Franchise

_update -- non-public methods are difficult to test in isolation
_update -- mock $franchise as \IBL\Franchise

\IBL\Franchise might need to be injected for testing purposes
\Exception might need to be injected for testing purposes
\Exception might need to be injected for testing purposes
\Exception might need to be injected for testing purposes
\Exception might need to be injected for testing purposes
\Exception might need to be injected for testing purposes

Feel free to hit me up on Twitter and pull requests to make the tool better are always welcome.

php-tricorder's People

Contributors

chartjes avatar gms8994 avatar dshafik avatar

Watchers

James Cloos avatar Peter Meth 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.