/** * If the call of the given frame index is a call from the class being tested. * * @param int $distanceFromThisCall * e.g. * bar calls foo, foo calls this method * To check about foo, specify 1. * To check about bar, specify 2. * * @return bool * @throws \Box\TestScribe\Exception\TestScribeException */ public function isCallFromTheClassBeingTested($distanceFromThisCall) { // The file path should be an absolute path. $inputSourceFilePath = $this->globalComputedConfig->getInSourceFile(); // Add one to the distance to take into consideration of the // additional frame between this call and // $this->callInformationCollector->getCallerInfoAt $callInfo = $this->callInformationCollector->getCallerInfoAt($distanceFromThisCall + 1); $filePathOfTheCaller = $callInfo->getFileName(); $isImmediateCall = $inputSourceFilePath === $filePathOfTheCaller; return $isImmediateCall; }
/** * @return string * @throws \Box\TestScribe\Exception\TestScribeException */ private function getCallerInfoString() { // #0 Box\TestScribe\_fixture\_input\CalculatorUtil->calc() // #1 mockClassInstance->add() // #2 mockClassInstance->__routeAllCallsToTestGeneratorMockObjects() // #3 Box\TestScribe\Mock\MockClass->invokeInterceptedCall() // #4 Box\TestScribe\Mock\MockClassService->invokeInterceptedCall() // #5 Box\TestScribe\Mock\MockClassServiceCallInfo::showCallInfo() // #6 Box\TestScribe\Mock\MockClassServiceCallInfo->getCallerInfoString() // @TODO (ryang 5/28/15) : find a better way to maintain this logic and add a test // for it. // It's easy to pass the wrong parameter // when adding or subtracting a layer of calls here. $callerLocationInfo = $this->callInformationCollector->getCallerInfoAt(7); $lineNumberString = $callerLocationInfo->getLineNumberString(); $callerInfoString = "line ( {$lineNumberString} )"; return $callerInfoString; }