use strict; use warnings; use Test::More; use Captcha::reCAPTCHA; # Looks real. Isn't. use constant PUBKEY => '6LdAAAkAwAAAFJj6ACG3Wlix_GuQJMNGjMQnw5UY'; my @schedule; BEGIN { my $pubkey = PUBKEY; @schedule = ( { name => 'Simple', args => [$pubkey], expect => qq{\n} . qq{\n} }, { name => 'Error', args => [ $pubkey, '<>' ], expect => qq{\n} . qq{\n} }, { name => 'Error in hash', args => [ $pubkey, { is_valid => 0, error => '<>' } ], expect => qq{\n} . qq{\n} }, { name => 'Secure', args => [ $pubkey, undef, 1 ], expect => qq{\n} . qq{\n} }, { name => 'Options', args => [ $pubkey, undef, 0, { theme => 'white', tabindex => 3 } ], expect => qq(\n) . qq{\n} . qq{\n} }, ); plan tests => 3 * @schedule; } for my $test ( @schedule ) { my $name = $test->{name}; ok my $captcha = Captcha::reCAPTCHA->new(), "$name: Created OK"; isa_ok $captcha, 'Captcha::reCAPTCHA'; my $args = $test->{args}; my $html = $captcha->get_html( @$args ); is $html, $test->{expect}, "$name: Generate HTML OK"; }