@BeforeScenario

@Given I reset the API context
199676
public function reset()
    {
        $this->headers = [];
        $this->request = null;
        $this->response = null;
        $this->multipartStreamBuilder = null;

        foreach ($this->resources as $resource) {
            if (is_resource($resource)) {
                fclose($resource);
            }
        }

        $this->resources = [];
    }
496545
public static function reset()
    {
        self::$apiKey = null;
        self::$isTest = false;
        self::$throwExceptions = false;
    }
126736
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        $query = $context->query;
        $services = array_keys(ComConnectHelperApi::getServices());
        $query->api($services);
    }
5141
public function prepareScenario(BeforeScenarioScope $scope) {
        $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-api-extension' . DIRECTORY_SEPARATOR . microtime(true);
        mkdir($dir . '/features/bootstrap', 0777, true);

        // Locate the php binary
        if (($bin = (new PhpExecutableFinder())->find()) === false) {
            throw new RuntimeException('Unable to find the PHP executable.');
        }

        $this->workingDir = $dir;
        $this->phpBin = $bin;
        $this->process = new Process(null);
    }
1006517
public function beforeScenario(BeforeScenarioScope $scope)
    {
        $core = $scope->getEnvironment()->getContext(CoreContext::class);
        /* @var FileTransport $transport */
        $transport = $core->getServiceManager()->get('Core/MailService')->getTransport();
        $path = $transport->getOptions()->getPath() . '/*.eml';
        foreach (glob($path) as $filename) {
            unlink($filename);
        }

        $this->subjects = $this->fromMails = $this->toMails = array();
    }
294176
protected void _before(SarlCapacityUses uses, IExtraLanguageGeneratorContext context) {
		// Rename the function in order to produce the good features at the calls.
		for (final JvmTypeReference capacity : uses.getCapacities()) {
			final JvmType type = capacity.getType();
			if (type instanceof JvmDeclaredType) {
				computeCapacityFunctionMarkers((JvmDeclaredType) type);
			}
		}
	}
781696
protected function resetInterpretedResponse()
    {
        $this->interpretedResponse = app(ServiceResponse::class);

        $this->interpretedResponse->setStatusCode(0);
        $this->interpretedResponse->setErrors([]);
        $this->interpretedResponse->setData(null);
    }
699015
function reset() {
		foreach ($this->fields as &$field) {
			$field['value']=NULL;
			$field['initial']=NULL;
			$field['changed']=FALSE;
			if ($field['pkey'])
				$field['previous']=NULL;
			unset($field);
		}
		foreach ($this->adhoc as &$field) {
			$field['value']=NULL;
			unset($field);
		}
		parent::reset();
	}
922512
public function beforeExecuteRoute() {
        $this->validateServicesDefined();
        $this->getDi()->set('Request', $this->request);
        $this->setStatusCode(200);
        $this->setOutputObject(new \stdClass());
        $this->response->setHeader('Access-Control-Allow-Origin', '*');
        try {
            $this->validateLogin();
        } catch(Exception $e) {
            $this->handleError($e);
            $this->afterExecuteRoute();
            exit;
        }
    }
278788
public function _beforeInit()
    {
        $this->pm = $this->add($this->pagemanager_class, $this->pagemanager_options);
        /** @type Controller_PageManager $this->pm */
        $this->pm->parseRequestedURL();
        parent::_beforeInit();
    }
488323
def before(self, context):
        ""
        run.before_each.execute(context)
        self._invoke(self._before, context)
773780
protected function beforeAction()
    {
        if (Lb::app()->isRest()) {
            $restConfig = Lb::app()->getRest()[$this->controller_id][$this->action_id];
            list($requestMethod, $authType) = $restConfig;

            $response = $this->response;

            //Set Auth Middleware
            $this->middleware['authMiddleware']['params'] = [
                'rest_config' => $restConfig,
                'request' => $this->request,
            ];
            $this->middleware['authMiddleware']['failureCallback'] = function () use ($response) {
                $response->response_unauthorized(401);
            };

            //Set Request Method Filter
            $this->middleware['requestMethodFilter']['params'] = [
                'request_method' => $requestMethod,
                'request' => $this->request,
            ];
            $this->middleware['requestMethodFilter']['failureCallback'] = function () use ($response) {
                $response->response_invalid_request(403);
            };

            //Set Rate Limit Filter
            if (array_key_exists($this->action_id, $this->rateLimitActions)) {
                $this->middleware['rateLimitFilter']['params'] = $this->rateLimitActions[$this->action_id];
                $this->middleware['rateLimitFilter']['failureCallback'] = function () use ($response) {
                    $response->response_invalid_request(403);
                };
            }
        } else {
            $this->response_invalid_request(403);
        }

        parent::beforeAction();
    }
1103805
protected function _beforeSend(DispatcherContext $context)
    {
        foreach($this->__authenticator_queue as $authenticator)
        {
            if($authenticator->challengeResponse($context) === true) {
                break;
            }
        }
    }
862976
public function clearContext()
    {
        $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class);
        $sessionDataContainer->reset();

        $this->roles = null;
        $this->contextHash = null;
        $this->activeTokens = [];
        $this->inactiveTokens = [];
        $this->request = null;
        $this->authorizationChecksDisabled = false;
        $this->initialized = false;
    }
1150418
public function beforeScenario(BeforeScenarioTested $event)
    {
        if ('scenario' !== $this->lifetime) {
            return;
        }

        list($adapter, $fixtureClass) = $this->extractAdapterConfig($event->getFeature()->getTags());

        $this->executor->changeAdapter($adapter, $fixtureClass);
        $this->executor->purge();
    }
260798
public function resetAction()
    {
        if ($this->resetSnippets) {
            $params = $this->_processParameters($this->resetParameters);

            $this->addSnippets($this->resetSnippets, $params);
        }
    }
342772
public function beforeFilter()
    {
        $authentication = $this->getAuthenticationService();
        $provider = $authentication->getAuthenticationProvider();

        if ($provider === null ||
            $provider instanceof PersistenceInterface ||
            $provider instanceof StatelessInterface
        ) {
            return;
        }

        $this->dispatchEvent('Authentication.afterIdentify', [
            'provider' => $provider,
            'identity' => $this->getIdentity(),
            'service' => $authentication
        ], $this->getController());
    }