AuthenticationConnectionFactorySpec.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace spec\Gaufrette\Adapter\RackspaceCloudfiles;
  3. use PhpSpec\ObjectBehavior;
  4. class AuthenticationConnectionFactorySpec extends ObjectBehavior
  5. {
  6. /**
  7. * @param \CF_Authentication $authentication
  8. */
  9. function let($authentication)
  10. {
  11. $this->beConstructedWith($authentication);
  12. }
  13. function it_is_initializable()
  14. {
  15. $this->shouldHaveType('Gaufrette\Adapter\RackspaceCloudfiles\AuthenticationConnectionFactory');
  16. $this->shouldHaveType('Gaufrette\Adapter\RackspaceCloudfiles\ConnectionFactoryInterface');
  17. }
  18. function it_creates_cf_connection($authentication)
  19. {
  20. $authentication->authenticated()->willReturn(true);
  21. $this->create()->shouldReturnAnInstanceOf('\CF_Connection');
  22. }
  23. function it_authenticates_when_was_not_authenticated_before($authentication)
  24. {
  25. $authentication->authenticated()->willReturn(false);
  26. $authentication->authenticate()->shouldBeCalled()->will(function () use ($authentication) {
  27. $authentication->authenticated()->willReturn(true);
  28. });
  29. $this->create()->shouldReturnAnInstanceOf('\CF_Connection');
  30. }
  31. }