HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/kk.ibovsl.com/vendor/simplesoftwareio/simple-qrcode/tests/BaconQrCodeGeneratorTest.php
<?php

use Mockery as m;
use PHPUnit\Framework\TestCase;
use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator;

class BaconQrCodeGeneratorTest extends TestCase
{
    public function tearDown()
    {
        if ($container = m::getContainer()) {
            $this->addToAssertionCount($container->mockery_getExpectationCount());
        }

        m::close();
    }

    public function setUp()
    {
        $this->writer = m::mock('\BaconQrCode\Writer');
        $this->format = m::mock('\BaconQrCode\Renderer\Image\RendererInterface');
        $this->qrCode = new BaconQrCodeGenerator($this->writer, $this->format);
    }

    public function test_it_sets_the_margin()
    {
        $this->format->shouldReceive('setMargin')
            ->with('50')
            ->once();

        $this->writer->shouldReceive('getRenderer')
            ->once()
            ->andReturn($this->format);

        $this->qrCode->margin(50);
    }

    public function test_it_sets_the_background_color()
    {
        $this->format->shouldReceive('setBackgroundColor')
            ->once();

        $this->writer->shouldReceive('getRenderer')
            ->once()
            ->andReturn($this->format);

        $this->qrCode->backgroundColor(255, 255, 255);
    }

    public function test_it_sets_the_foreground_color()
    {
        $this->format->shouldReceive('setForegroundColor')
            ->once();

        $this->writer->shouldReceive('getRenderer')
            ->once()
            ->andReturn($this->format);

        $this->qrCode->color(255, 255, 255);
    }

    public function test_it_sets_the_size()
    {
        $this->format->shouldReceive('setHeight')
            ->with(50)
            ->once();
        $this->format->shouldReceive('setWidth')
            ->with(50)
            ->once();

        $this->writer->shouldReceive('getRenderer')
            ->twice()
            ->andReturn($this->format);

        $this->qrCode->size(50);
    }

    public function test_it_sets_a_png_format()
    {
        $this->writer->shouldReceive('setRenderer')
            ->with('BaconQrCode\Renderer\Image\Png')
            ->once();

        $this->qrCode->format('png');
    }

    public function test_it_sets_a_eps_format()
    {
        $this->writer->shouldReceive('setRenderer')
            ->with('BaconQrCode\Renderer\Image\Eps')
            ->once();

        $this->qrCode->format('eps');
    }

    public function test_it_sets_a_svg_format()
    {
        $this->writer->shouldReceive('setRenderer')
            ->with('BaconQrCode\Renderer\Image\Svg')
            ->once();

        $this->qrCode->format('svg');
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function test_it_throws_an_exception_with_an_invalid_format()
    {
        $this->qrCode->format('random');
    }

    public function test_it_generates_a_string()
    {
        $this->writer->shouldReceive('writeString')
            ->with('qrCode', m::type('string'), m::type('int'))
            ->once();

        $this->qrCode->generate('qrCode');
    }

    public function test_it_calls_a_valid_dynamic_method_and_generates_a_qrcode()
    {
        $this->writer->shouldReceive('writeString')
            ->once();

        $this->qrCode->phoneNumber('555-555-5555');
    }

    /**
     * @expectedException \BadMethodCallException
     */
    public function test_it_throws_an_exception_if_datatype_is_not_found()
    {
        $this->qrCode->notReal('foo');
    }
}