API Upgrade to use new AssetStore service name

This commit is contained in:
Damian Mooyman 2017-05-16 14:42:47 +12:00
parent 4f3d3fdbab
commit 1993e5d305
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
5 changed files with 14 additions and 12 deletions

View File

@ -22,7 +22,7 @@ matrix:
before_script: before_script:
- composer validate - composer validate
- composer install --dev --prefer-dist - composer install --dev --prefer-dist
- composer require silverstripe/config:1.0.x-dev silverstripe/framework:4.0.x-dev --prefer-dist - composer require --update-with-dependencies silverstripe/framework:4.0.x-dev silverstripe/siteconfig:4.0.x-dev silverstripe/config:1.0.x-dev silverstripe/assets:1.0.x-dev silverstripe/versioned:1.0.x-dev --prefer-dist
- if [[ $PHPCS_TEST ]]; then pyrus install pear/PHP_CodeSniffer; fi - if [[ $PHPCS_TEST ]]; then pyrus install pear/PHP_CodeSniffer; fi
- phpenv rehash - phpenv rehash

View File

@ -302,7 +302,9 @@ of the `TestSessionEnvironment`, in order to share it with Behat CLI.
Example: Retrieve the currently logged-in member Example: Retrieve the currently logged-in member
$env = Injector::inst()->get('TestSessionEnvironment'); use SilverStripe\TestSession\TestsessionEnvironment;
$env = Injector::inst()->get(TestSessionEnvironment::class);
$state = $env->getState(); $state = $env->getState();
if(isset($state->session['loggedInAs'])) { if(isset($state->session['loggedInAs'])) {
$member = \Member::get()->byID($state->session['loggedInAs']); $member = \Member::get()->byID($state->session['loggedInAs']);

View File

@ -28,7 +28,7 @@
"behat/mink-extension": "^2.1", "behat/mink-extension": "^2.1",
"behat/mink-selenium2-driver": "^1.3", "behat/mink-selenium2-driver": "^1.3",
"symfony/dom-crawler": "^3", "symfony/dom-crawler": "^3",
"silverstripe/testsession": "2.0.0-alpha6", "silverstripe/testsession": "~2.0.0@alpha",
"silverstripe/framework": "^4@dev", "silverstripe/framework": "^4@dev",
"symfony/finder": "^3.2" "symfony/finder": "^3.2"
}, },

View File

@ -36,7 +36,7 @@ There's several parts to this:
How the pieces fit together is best illustrated as an example. How the pieces fit together is best illustrated as an example.
We'll create a currency rate viewer, We'll create a currency rate viewer,
based on a [free online webservice](http://www.webservicex.net/CurrencyConvertor.asmx?WSDL). based on a [free online webservice](http://www.webservicex.net/CurrencyConvertor.asmx?WSDL).
The example assumes you have a basic knowledge of [Behat](http://behat.org) and The example assumes you have a basic knowledge of [Behat](http://behat.org) and
the [Behat SilverStripe extension](https://github.com/silverstripe-labs/silverstripe-behat-extension). the [Behat SilverStripe extension](https://github.com/silverstripe-labs/silverstripe-behat-extension).
Let's explain the feature through the Gherkin language as Behat steps: Let's explain the feature through the Gherkin language as Behat steps:
@ -81,7 +81,7 @@ class CurrencyGateway {
The controller logic for this is really simple. The controller logic for this is really simple.
We'll stick to request parameters and plaintext responses just to keep the code We'll stick to request parameters and plaintext responses just to keep the code
manageable, a more realistic controller would likely use a form and HTML formatted responses. manageable, a more realistic controller would likely use a form and HTML formatted responses.
Its important that our `CurrencyGateway` is instanciated through the Its important that our `CurrencyGateway` is instanciated through the
use of [dependency injection](http://doc.silverstripe.org/framework/en/trunk/reference/injector), use of [dependency injection](http://doc.silverstripe.org/framework/en/trunk/reference/injector),
so we can replace its implementation with a mock object later. so we can replace its implementation with a mock object later.
@ -114,6 +114,7 @@ Open the already generated `FeatureContext.php` file and add the following code.
```php ```php
// mysite/tests/behat/features/bootstrap/Context/FeatureContext.php // mysite/tests/behat/features/bootstrap/Context/FeatureContext.php
use namespace SilverStripe\TestSession\TestSessionStubCodeWriter;
class FeatureContext extends SilverStripeContext { class FeatureContext extends SilverStripeContext {
protected $stubCodeWriter; protected $stubCodeWriter;
@ -121,7 +122,7 @@ class FeatureContext extends SilverStripeContext {
public function __construct() { public function __construct() {
// ... // ...
$this->stubCodeWriter = Injector::inst()->get('TestSessionStubCodeWriter'); $this->stubCodeWriter = Injector::inst()->get(TestSessionStubCodeWriter::class);
} }
/** /**
@ -169,7 +170,7 @@ avoid side effects (hence the methods tagged with `@BeforeScenario` and `@AfterS
A useful pattern here is to set up objects via `@BeforeScenario`, in our case A useful pattern here is to set up objects via `@BeforeScenario`, in our case
a mock gateway in `initTestSessionStubCode()`. This object can be used in later a mock gateway in `initTestSessionStubCode()`. This object can be used in later
step definitions like `stepGivenACurrency()` to mock webservice responses step definitions like `stepGivenACurrency()` to mock webservice responses
without any further setup or duplication. without any further setup or duplication.
The generated code which is executed on every web request reads: The generated code which is executed on every web request reads:
@ -180,8 +181,8 @@ Injector::inst()->registerService($mock, 'CurrencyGateway');
Phockito::when($mock->convert('EUR','NZD'))->return(1.56); Phockito::when($mock->convert('EUR','NZD'))->return(1.56);
``` ```
Keep in mind escaping rules for PHP when placed in a heredoc block: Keep in mind escaping rules for PHP when placed in a heredoc block:
Variables are resolved when the string is constructed, unless escaped with a backslash. Variables are resolved when the string is constructed, unless escaped with a backslash.
The test session started in your browser by Selenium/Behat needs to know The test session started in your browser by Selenium/Behat needs to know
which file to include, which is handled by the `getTestSessionState()` method. which file to include, which is handled by the `getTestSessionState()` method.

View File

@ -761,12 +761,11 @@ class FixtureContext implements Context
} }
/** /**
*
* @return AssetStore * @return AssetStore
*/ */
protected function getAssetStore() protected function getAssetStore()
{ {
return singleton('AssetStore'); return Injector::inst()->get(AssetStore::class);
} }
/** /**