PHP code example of peterfox / behat-resources-extension
1. Go to this page and download the library: Download peterfox/behat-resources-extension library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
peterfox / behat-resources-extension example snippets
use BehatResources\Context\ResourceContext;
class FeatureContext extends MinkContext implements ResourceContext
{
private $builder;
/**
* @param ResourceBuilder $builder
*/
public function setResourceBuilder(ResourceBuilder $builder)
{
$this->builder = $builder;
}
/**
* @param $type
* @param $identifier
* @return array
*/
public function getResource($type, $identifier)
{
return $this->resourceBuilder->getLoader()->load($type, $identifier);
}
/**
* @param $type
* @param $identifier
* @return object
*/
public function getResourceObject($type, $identifier)
{
return $this->resourceBuilder->build($type, $identifier);
}
/**
* @param $type
* @param $identifier
* @return object
*/
public function getPersistedResourceObject($type, $identifier)
{
return $this->resourceBuilder->build($type, $identifier);
}
/**
* Returns your implementation of the ResourceFactory for changing resources into Objects/Models/Entities etc.
*
* @return ResourceFactory|null
*/
public function getResourceFactory()
{
return new EloquentResourceFactory();
}
}
/**
* @Given /^there is a ([^"]*) called "([^"]*)"$/
*/
public function thereIsACalled($resource, $name)
{
$this->getPersistedResourceObject($resource, $name);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.