Zac

Had asked a question -- moved it to #testing because testing specific. 🕺

Zac
Zac in #backend 2020-07-26 23:23:19 (edited) (deleted)

During setUp():

  1. Injector::nest();
  2. Injector::inst()->registerService(
  3. new HTTPRequest('GET', 'doesnt-matter', [
  4. 'deviceID' => 'totally-real-id',
  5. ]),
  6. HTTPRequest::class
  7. );

-- happens if either before or after parent::setUp()

Zac

e.g.:

  1. Double\SilverStripe\Control\HTTPRequest\P6]8;;file:///#-website/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code#L2\^]8;;\ {#20301
  2. -objectProphecyClosure: Closure()]8;;file:///#-website/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code#L170\^]8;;\ {#20485
  3. class: "]8;;file:///#-website/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code#L2\Double\SilverStripe\Control\HTTPRequest\P6]8;;\"
  4. this: Double\SilverStripe\Control\HTTPRequest\P6]8;;file:///#-website/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code#L2\^]8;;\ {#20301}
  5. use: {
  6. $prophecy: Prophecy\Prophecy\ObjectProphecy {#20387 …}
  7. }
  8. }
  9. #url: null
  10. #dirParts: null
  11. #extension: null
  12. #httpMethod: null
  13. #scheme: null
  14. #ip: null
  15. #getVars: []
  16. #postVars: []
  17. #headers: []
  18. #body: null
  19. #allParams: []
  20. #latestParams: []
  21. #routeParams: []
  22. #unshiftedButParsedParts: 0
  23. #session: null
  24. }
Zac

Nesting the Injector + trying to return my own HTTPRequest is still having the Injector::inst()->get(HTTPRequest::class) return the SapphireTest mocked version and not my own.

Zac

^ framework version is 4.5.0 if my composer.lock is to be believed

Zac
Zac in #backend 2020-07-26 23:07:15 (edited) (deleted)

I need to mock out the Request for some tests, but the Sapphire test thing is mocking it with something already that doesn't fulfil the requirements I have - how can I replace it? Init from vendor/silverstripe/framework/src/Dev/SapphireTest.php:991

Zac

Ah - looks like we're setting our session handler from PHP's INI side. session.save_handler = redis

✔️ (1)
Zac

Hey there - does SS use different session handlers other than the $_SESSION super global? I can't seem to find references where it copies data from that to an alternative destination

novalix

Hi there, i am working on a migration path from an ancient Java Website to Silverstripe. Be prepared for some questions :-)

👍 (1)