Amal_Udjir/tests/Functional/LoginTest.php
2025-05-09 05:04:11 +07:00

132 lines
4.1 KiB
PHP

<?php
namespace Tests\Functional;
use Tests\Support\FunctionalTester;
class LoginTest extends \Codeception\Test\Unit
{
protected FunctionalTester $tester;
protected function _before(){
}
// tests
public function testLatihanNumberOne()
{
$I = $this->tester;
$I->amOnPage('/phpunit/result-test-student/');
$responseContent = $I->grabPageSource();
$row = $this->tester->grabFromDatabase('php_testing_rule', 'testing_rule', [
'testing_name' => 'testing_number_one'
]);
$test = str_replace(["\r\n", "\r", "\n", " "], "", $row);
$result_test = htmlspecialchars($test); // hasilnya: &lt;?phpecho1;?&gt;
$result_content = str_replace(["\r\n", "\r", "\n", " "], "", $responseContent); // TANPA htmlentities
$this->assertStringContainsString(
$result_test,
$result_content,
"❌ ERROR: String $result_test tidak ditemukan di halaman!"
);
}
public function testLatihanNumberTwo()
{
$I = $this->tester;
$I->amOnPage('/phpunit/result-test-student/');
$responseContent = $I->grabPageSource();
$row = $this->tester->grabFromDatabase('php_testing_rule', 'testing_rule', [
'testing_name' => 'testing_number_two'
]);
$test = str_replace(["\r\n", "\r", "\n", " "], "", $row);
$result_test = htmlspecialchars($test); // hasilnya: &lt;?phpecho1;?&gt;
$result_content = str_replace(["\r\n", "\r", "\n", " "], "", $responseContent); // TANPA htmlentities
$this->assertStringContainsString(
$result_test,
$result_content,
"❌ ERROR: String $result_test tidak ditemukan di halaman!"
);
}
public function testLatihanNumberThree()
{
$I = $this->tester;
$I->amOnPage('/phpunit/result-test-student/');
$responseContent = $I->grabPageSource();
$row = $this->tester->grabFromDatabase('php_testing_rule', 'testing_rule', [
'testing_name' => 'testing_number_three'
]);
$test = str_replace(["\r\n", "\r", "\n", " "], "", $row);
$result_test = htmlspecialchars($test); // hasilnya: &lt;?phpecho1;?&gt;
$result_content = str_replace(["\r\n", "\r", "\n", " "], "", $responseContent); // TANPA htmlentities
$this->assertStringContainsString(
$result_test,
$result_content,
"❌ ERROR: String $result_test tidak ditemukan di halaman!"
);
}
public function testLatihanNumberFour()
{
$I = $this->tester;
$I->amOnPage('/phpunit/result-test-student/');
$responseContent = $I->grabPageSource();
$row = $this->tester->grabFromDatabase('php_testing_rule', 'testing_rule', [
'testing_name' => 'testing_number_four'
]);
$test = str_replace(["\r\n", "\r", "\n", " "], "", $row);
$result_test = htmlspecialchars($test); // hasilnya: &lt;?phpecho1;?&gt;
$result_content = str_replace(["\r\n", "\r", "\n", " "], "", $responseContent); // TANPA htmlentities
$this->assertStringContainsString(
$result_test,
$result_content,
"❌ ERROR: String $result_test tidak ditemukan di halaman!"
);
}
public function testLatihanNumberFive()
{
$I = $this->tester;
$I->amOnPage('/phpunit/result-test-student/');
$responseContent = $I->grabPageSource();
$row = $this->tester->grabFromDatabase('php_testing_rule', 'testing_rule', [
'testing_name' => 'testing_number_five'
]);
$test = str_replace(["\r\n", "\r", "\n", " "], "", $row);
$result_test = htmlspecialchars($test); // hasilnya: &lt;?phpecho1;?&gt;
$result_content = str_replace(["\r\n", "\r", "\n", " "], "", $responseContent); // TANPA htmlentities
$this->assertStringContainsString(
$result_test,
$result_content,
"❌ ERROR: String $result_test tidak ditemukan di halaman!"
);
}
}