Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/PendingBatchFake.php
Строк: 73
<?php

namespace IlluminateSupportTestingFakes;

use 
Closure;
use 
IlluminateBusPendingBatch;
use 
IlluminateSupportCollection;
use 
IlluminateSupportTraitsReflectsClosures;

class 
PendingBatchFake extends PendingBatch
{
    use 
ReflectsClosures;

    
/**
     * The fake bus instance.
     *
     * @var IlluminateSupportTestingFakesBusFake
     */
    
protected $bus;

    
/**
     * Create a new pending batch instance.
     *
     * @param  IlluminateSupportTestingFakesBusFake  $bus
     * @param  IlluminateSupportCollection  $jobs
     */
    
public function __construct(BusFake $busCollection $jobs)
    {
        
$this->bus $bus;
        
$this->jobs $jobs->filter()->values();
    }

    
/**
     * Dispatch the batch.
     *
     * @return IlluminateBusBatch
     */
    
public function dispatch()
    {
        return 
$this->bus->recordPendingBatch($this);
    }

    
/**
     * Dispatch the batch after the response is sent to the browser.
     *
     * @return IlluminateBusBatch
     */
    
public function dispatchAfterResponse()
    {
        return 
$this->bus->recordPendingBatch($this);
    }

    
/**
     * Determine if the jobs in the batch match the given jobs.
     *
     * @param  array  $expectedJobs
     * @return bool
     */
    
public function hasJobs(array $expectedJobs)
    {
        if (
count($this->jobs) !== count($expectedJobs)) {
            return 
false;
        }

        foreach (
$expectedJobs as $index => $expectedJob) {
            if (
$expectedJob instanceof Closure) {
                
$expectedType $this->firstClosureParameterType($expectedJob);

                if (! 
$this->jobs[$index] instanceof $expectedType) {
                    return 
false;
                }

                if (! 
$expectedJob($this->jobs[$index])) {
                    return 
false;
                }
            } elseif (
is_string($expectedJob)) {
                if (
$expectedJob != get_class($this->jobs[$index])) {
                    return 
false;
                }
            } elseif (
serialize($expectedJob) != serialize($this->jobs[$index])) {
                return 
false;
            }
        }

        return 
true;
    }
}
Онлайн: 0
Реклама