from Hacker News

Parody – a PHP testing library

by mattsah on 1/12/13, 10:03 PM with 37 comments

  • by freework on 1/13/13, 12:03 AM

    I'm confused, what does this have to do with Aaron Swartz?
  • by sentiental on 1/12/13, 11:02 PM

    There are a number of mock object libraries out there (mockery, shmock, phpunit's mock syntax, etc). This just looks like another builder syntax for making mocks / stubs with some fanciness around class extension - what's the benefit?

    Also, how often is it useful to define a class at test time that is initialized by production code (from the section I Still Have Serious Dependency Issues!). This seems like an unlikely use case.

  • by 0x0 on 1/13/13, 12:30 AM

    Noticing it's licensed under AGPL. I guess that means all projects that happen to include this (or something depending on it) would then be required to post full source code on the webpage, even if the project is for a single install?
  • by wvenable on 1/13/13, 3:23 AM

    Since this library requires PHP 5.4, I'm not sure why it bothers with this syntax:

        Parody\Mime::create('Vendor\Class\Project')
        -> onCall('method') -> expect('argument one') ->  give('response one')
        -> onCall('method') -> expect('argument two') -> give('response two')
        -> resolve();
    
    When one could just use anonymous functions to give the same result with less API-as-code.

        Parody\Mime::create('Vendor\Class\Project')
        -> onCall('method', function($param) {
          if ($param == 'argument one') return 'response one';
          if ($param == 'argument two') return 'response two';
        ) -> resolve();
    
    This is more flexible, less code for the framework, and easier to learn.
  • by Gigablah on 1/13/13, 12:07 AM

    This library could use Composer support. I suppose I'll make a quick pull request.
  • by parf73 on 1/13/13, 2:07 AM

    great simplistic php testing framework: https://github.com/parf/spartan-test