Aliyya_Putri_Setiyomadani/form-testing/tests/ProsesFormRequiredTest.php
2024-12-31 11:09:29 +07:00

41 lines
1.1 KiB
PHP

<?php
require_once __DIR__ . '/helper/TestResultsManager.php';
use PHPUnit\Framework\TestCase;
class ProsesFormRequiredTest extends TestCase
{
private $testResultsManager;
protected function setUp(): void
{
$this->testResultsManager = new TestResultsManager();
}
public function testSuccessfulSubmission()
{
try {
$testCase = get_class($this) . '.' . __FUNCTION__;
$_GET['yourname'] = 'AliyyaPS';
$_GET['youraddress'] = 'Sidoarjo';
ob_start();
include_once './apps/prosesFormRequired.php';
$output = ob_get_clean();
$dom = new DOMDocument();
$dom->loadHTML($output);
$this->assertStringContainsString('Your Name: AliyyaPS', $dom->textContent);
$this->assertStringContainsString('Your Address: Sidoarjo', $dom->textContent);
$this->testResultsManager->showTestResult($testCase);
} catch (\Throwable $e) {
$this->testResultsManager->showTestResult($testCase, $e);
throw $e;
}
}
}