mageekguy\atoum\asserters\adapter\call::countBeforeAndAfterCalls PHP Method

countBeforeAndAfterCalls() protected method

protected countBeforeAndAfterCalls ( )
    protected function countBeforeAndAfterCalls()
    {
        $calls = $this->callIsSet()->adapter->getCalls($this->call, $this->identicalCall);
        if (sizeof($calls) > 0 && (sizeof($this->beforeCalls) > 0 || sizeof($this->afterCalls) > 0)) {
            foreach ($this->beforeCalls as $asserter) {
                $pass = false;
                foreach ($calls->getTimeline() as $position => $call) {
                    $hasAfterCalls = $asserter->hasAfterCalls($position);
                    if ($hasAfterCalls === false) {
                        $calls->removeCall($call, $position);
                    } else {
                        if ($pass === false) {
                            $pass = $hasAfterCalls;
                        }
                    }
                }
                if ($pass === false) {
                    $this->fail($this->_('%s is not called before %s', $this->call, $asserter->getCall()));
                }
            }
            foreach ($this->afterCalls as $asserter) {
                $pass = false;
                foreach ($calls->getTimeline() as $position => $call) {
                    $hasPreviousCalls = $asserter->hasPreviousCalls($position);
                    if ($hasPreviousCalls === false) {
                        $calls->removeCall($call, $position);
                    } else {
                        if ($pass === false) {
                            $pass = $hasPreviousCalls;
                        }
                    }
                }
                if ($pass === false) {
                    $this->fail($this->_('%s is not called after %s', $this->call, $asserter->getCall()));
                }
            }
        }
        return sizeof($calls);
    }