File size: 938 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

declare(strict_types=1);

namespace Mautic\CoreBundle\Tests\Command;

use Mautic\CoreBundle\Entity\IpAddress;
use Mautic\CoreBundle\Entity\IpAddressRepository;
use Mautic\CoreBundle\Test\MauticMysqlTestCase;

class UnusedIpDeleteCommandFunctionalTest extends MauticMysqlTestCase
{
    /**
     * @throws \Exception
     */
    public function testUnusedIpDeleteCommand(): void
    {
        // Emulate unused IP address.
        /** @var IpAddressRepository $ipAddressRepo */
        $ipAddressRepo = $this->em->getRepository(IpAddress::class);
        $ipAddressRepo->saveEntity(new IpAddress('127.0.0.1'));
        $count = $ipAddressRepo->count(['ipAddress' => '127.0.0.1']);
        self::assertSame(1, $count);

        // Delete unused IP address.
        $this->testSymfonyCommand('mautic:unusedip:delete');

        $count = $ipAddressRepo->count(['ipAddress' => '127.0.0.1']);
        self::assertSame(0, $count);
    }
}