SpambotUserspamTest.php in Spambot 8
File
tests/src/Kernel/SpambotUserspamTest.php
View source
<?php
namespace Drupal\Tests\spambot\Kernel;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;
class SpambotUserspamTest extends KernelTestBase implements ServiceModifierInterface {
protected $user;
public static $modules = [
'spambot',
'user',
];
public function setUp() : void {
parent::setUp();
$this->user = User::create([
'name' => 'amparohm69',
'mail' => 'nelda@singaporetravel.network',
]);
}
public function testSpambotReportAccountEmptyApiKey() {
$key = '';
$success = spambot_report_account($this->user, '130.176.13.140', 'title', $key);
$this
->assertFalse($success, 'Field api key should not be filled.');
}
public function testSpambotReportAccountIncorrectApiKey() {
$key = 'notExist503';
$success = spambot_report_account($this->user, '130.176.13.140', 'title', $key);
$this
->assertFalse($success, 'Field api key should not be filled.');
}
public function testSpambotReportSpamAccount() {
$key = 'wqd31vfkhae9gn';
$success = spambot_report_account($this->user, '130.176.13.140', 'title', $key);
$this
->assertTrue($success, 'Guzzle exception.');
}
public function alter(ContainerBuilder $container) {
$container
->removeDefinition('test.http_client.middleware');
}
}