Issues (3627)

app/bundles/SmsBundle/Tests/Model/SmsModelTest.php (1 issue)

1
<?php
2
3
namespace Mautic\SmsBundle\Tests\Model;
4
5
use Mautic\CoreBundle\Security\Permissions\CorePermissions;
6
use Mautic\SmsBundle\Entity\SmsRepository;
7
use Mautic\SmsBundle\Form\Type\SmsType;
8
use Mautic\SmsBundle\Model\SmsModel;
9
10
class SmsModelTest extends \PHPUnit\Framework\TestCase
11
{
12
    /**
13
     * Test to get lookup results when class name is sent as a parameter.
14
     */
15
    public function testGetLookupResultsWhenTypeIsClass()
16
    {
17
        $entities       = [['name' => 'Mautic', 'id' => 1, 'language' => 'cs']];
18
        $repositoryMock = $this->createMock(SmsRepository::class);
19
        $repositoryMock->method('getSmsList')
20
            ->with('', 10, 0, true, false)
21
            ->willReturn($entities);
22
        // Partial mock, mocks just getRepository
23
        $smsModel = $this->getMockBuilder(SmsModel::class)
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

23
        $smsModel = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder(SmsModel::class)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
24
            ->disableOriginalConstructor()
25
            ->setMethods(['getRepository'])
26
            ->getMock();
27
        $smsModel->method('getRepository')
28
            ->willReturn($repositoryMock);
29
        $securityMock = $this->createMock(CorePermissions::class);
30
        $securityMock->method('isGranted')
31
            ->with('sms:smses:viewother')
32
            ->willReturn(true);
33
        $smsModel->setSecurity($securityMock);
34
        $textMessages = $smsModel->getLookupResults(SmsType::class);
35
        $this->assertSame('Mautic', $textMessages['cs'][1], 'Mautic is the right text message name');
36
    }
37
}
38