package TAP::Parser::SourceHandler::PHP; use warnings; use strict; use TAP::Parser::IteratorFactory (); use TAP::Parser::Iterator::Process (); our @ISA = qw( TAP::Parser::SourceHandler ); TAP::Parser::IteratorFactory->register_handler(__PACKAGE__); =head1 NAME TAP::Parser::SourceHandler::PHP - Runs PHP programs to get their TAP for prove =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS This module is a plugin to let you run PHP programs under F. prove --source Perl \ --source PHP --php-option include_path=/tmp/foo =head1 CLASS METHODS =head2 $handler->can_handle( $source ) Tells whether we should handle the file as a PHP test. =cut sub can_handle { my ( $class, $source ) = @_; my $meta = $source->meta; my $config = $source->config_for( 'PHP' ); return 0 unless $meta->{is_file}; my $suf = $meta->{file}{lc_ext}; my $wanted_extension = $config->{extension} || '.php'; return 1 if $suf eq $wanted_extension; return 0; } =head2 C my $iterator = $class->make_iterator( $source ); Returns a new iterator for the source. C<< $source->raw >> must be either a file name or a scalar reference to the file name. =over =item include_path Paths to include for PHP to search for files. =back =cut sub make_iterator { my ( $class, $source ) = @_; my $config = $source->config_for('PHP'); my @command = ( $config->{php} || '/usr/local/bin/php' ); my $include_path = $config->{include_path}; if ( $include_path ) { push( @command, "-dinclude_path=$include_path" ); } my $fn = ref $source->raw ? ${ $source->raw } : $source->raw; push( @command, $fn ); return TAP::Parser::Iterator::Process->new( { command => \@command, merge => $source->merge }); } =head1 SEE ALSO L, L, L, L, L, L, L, L, L =head1 AUTHOR Andy Lester, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc TAP::Parser::SourceHandler::PHP You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS Thanks to David Wheeler for being able to steal from his pgTAP SourceHandler. L =head1 LICENSE AND COPYRIGHT Copyright 2010 Andy Lester. This program is released under the Artistic License v2.0. =cut 1; # End of TAP::Parser::SourceHandler::PHP