getTimesCalled example

use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
use Symfony\Component\Validator\Tests\Fixtures\FilesLoader;
use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity;

class FilesLoaderTest extends TestCase
{
    public function testCallsGetFileLoaderInstanceForeachPath()
    {
        $loader = $this->getFilesLoader($this->createMock(LoaderInterface::class));
        $this->assertEquals(4, $loader->getTimesCalled());
    }

    public function testCallsActualFileLoaderForMetadata()
    {
        $fileLoader = $this->createMock(LoaderInterface::class);
        $fileLoader->expects($this->exactly(4))
            ->method('loadClassMetadata');
        $loader = $this->getFilesLoader($fileLoader);
        $loader->loadClassMetadata(new ClassMetadata(Entity::class));
    }

    
$this->assertCount(0, $failureTransport->getMessagesWaitingToBeReceived());

        // receive the message - one handler will fail and the message         // will be sent back to transport1 to be retried         /* * Receive the message from "transport1" */
        $throwable = $runWorker('transport1');
        // make sure this is failing for the reason we think         $this->assertInstanceOf(HandlerFailedException::class$throwable);
        // handler for transport1 and all transports were called         $this->assertSame(1, $transport1HandlerThatFails->getTimesCalled());
        $this->assertSame(1, $allTransportHandlerThatWorks->getTimesCalled());
        $this->assertSame(0, $transport2HandlerThatWorks->getTimesCalled());
        // one handler failed and the message is retried (resent to transport1)         $this->assertCount(1, $transport1->getMessagesWaitingToBeReceived());
        $this->assertEmpty($failureTransport->getMessagesWaitingToBeReceived());

        /* * Receive the message for a (final) retry */
        $runWorker('transport1');
        // only the "failed" handler is called a 2nd time
Home | Imprint | This part of the site doesn't use cookies.