Skip to content

Commit

Permalink
test: added tests for cli tool
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ committed Dec 9, 2024
1 parent 368a68a commit 072dbe2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Feature/CliTool.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

it('returns an ip', function () {
exec('php cli/publicip.php', $output, $result_code);

expect($result_code)->toBe(0)
->and(filter_var($output[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6))->toBeString();
});

it('returns an ipv4', function () {
exec('php cli/publicip.php --ipv4', $output, $result_code);

expect($result_code)->toBe(0)
->and(filter_var($output[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))->toBeString();
});

it('returns an ipv6', function () {
exec('php cli/publicip.php --ipv6', $output, $result_code);

expect($result_code)->toBe(0)
->and(filter_var($output[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))->toBeString();
});

0 comments on commit 072dbe2

Please sign in to comment.