Restructure tests

- Avoid database leftovers
This commit is contained in:
Philipp 2023-02-13 20:52:24 +01:00
parent 704508fc65
commit e1813e3d73
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
11 changed files with 161 additions and 104 deletions

View file

@ -21,15 +21,15 @@
namespace Friendica\Test\src\Console;
use Dice\Dice;
use Friendica\Console\ServerBlock;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\DI;
use Friendica\Moderation\DomainPatternBlocklist;
use Friendica\Test\FixtureTestTrait;
use Mockery;
class ServerBlockConsoleTest extends ConsoleTest
{
use FixtureTestTrait;
protected $defaultBlockList = [
[
'domain' => 'social.nobodyhasthe.biz',
@ -49,9 +49,18 @@ class ServerBlockConsoleTest extends ConsoleTest
{
parent::setUp();
$this->setUpFixtures();
$this->blocklistMock = Mockery::mock(DomainPatternBlocklist::class);
}
protected function tearDown(): void
{
$this->tearDownFixtures();
parent::tearDown();
}
/**
* Test to list the default blocked servers
*/
@ -80,11 +89,6 @@ CONS;
*/
public function testAddBlockedServer()
{
$dice = new Dice();
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
DI::init($dice, true);
$this->blocklistMock
->shouldReceive('addPattern')
->with('testme.now', 'I like it!')
@ -105,11 +109,6 @@ CONS;
*/
public function testUpdateBlockedServer()
{
$dice = new Dice();
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
DI::init($dice, true);
$this->blocklistMock
->shouldReceive('addPattern')
->with('pod.ordoevangelistarum.com', 'Other reason')
@ -130,11 +129,6 @@ CONS;
*/
public function testRemoveBlockedServer()
{
$dice = new Dice();
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
DI::init($dice, true);
$this->blocklistMock
->shouldReceive('removePattern')
->with('pod.ordoevangelistarum.com')