1919 */
2020namespace OpenStack \Tests \ObjectStore \v1 \Resource ;
2121
22- use \ OpenStack \ObjectStore \ v1 \ Resource \ StreamWrapperFS ;
23- use \ OpenStack \ObjectStore \v1 \Resource \Container ;
24- use \ OpenStack \ObjectStore \ v1 \ Resource \ Object ;
22+ use OpenStack \Common \ Transport \ Exception \ FileNotFoundException ;
23+ use OpenStack \ObjectStore \v1 \Resource \StreamWrapperFS ;
24+ use OpenStack \Tests \ TestCase ;
2525
2626/**
2727 * @group streamWrapper
2828 */
29- class StreamWrapperFSTest extends \ OpenStack \ Tests \ TestCase
29+ class StreamWrapperFSTest extends TestCase
3030{
3131 const FNAME = 'streamTest.txt ' ;
3232 const FTYPE = 'application/x-tuna-fish; charset=iso-8859-13 ' ;
3333
34- /*public static function setUpBeforeClass() {
35- }*/
36-
3734 /**
3835 * Cleaning up the test container so we can reuse it for other tests.
3936 */
4037 public static function tearDownAfterClass ()
4138 {
42- // First we get an identity
43- $ user = self ::conf ('openstack.identity.username ' );
44- $ pass = self ::conf ('openstack.identity.password ' );
45- $ tenantId = self ::conf ('openstack.identity.tenantId ' );
46- $ url = self ::conf ('openstack.identity.url ' );
47-
48- $ ident = new \OpenStack \Identity \v2 \IdentityService ($ url , self ::getTransportClient ());
49-
50- $ token = $ ident ->authenticateAsUser ($ user , $ pass , $ tenantId );
51-
52- // Then we need to get an instance of storage
53- $ store = \OpenStack \ObjectStore \v1 \ObjectStorage::newFromIdentity ($ ident , self ::conf ('openstack.swift.region ' ), self ::getTransportClient ());
39+ /** @var \OpenStack\ObjectStore\v1\ObjectStore $store */
40+ $ store = self ::createObjectStoreService ();
5441
5542 // Delete the container and all the contents.
5643 $ cname = self ::$ settings ['openstack.swift.container ' ];
@@ -59,7 +46,7 @@ public static function tearDownAfterClass()
5946 $ container = $ store ->container ($ cname );
6047 }
6148 // The container was never created.
62- catch (\ OpenStack \ Common \ Transport \ Exception \ FileNotFoundException $ e ) {
49+ catch (FileNotFoundException $ e ) {
6350 return ;
6451 }
6552
@@ -121,30 +108,24 @@ protected function basicSwiftContext($add = array(), $scheme = null)
121108 * UPDATE: This now users IdentityService instead of deprecated
122109 * swauth.
123110 */
124- protected function authSwiftContext ($ add = array () , $ scheme = null )
111+ protected function authSwiftContext (array $ params = [] , $ scheme = null )
125112 {
126- $ cname = self ::$ settings ['openstack.swift.container ' ];
127- $ username = self ::$ settings ['openstack.identity.username ' ];
128- $ password = self ::$ settings ['openstack.identity.password ' ];
129- $ tenant = self ::$ settings ['openstack.identity.tenantId ' ];
130- $ baseURL = self ::$ settings ['openstack.identity.url ' ];
131-
132113 if (empty ($ scheme )) {
133114 $ scheme = StreamWrapperFS::DEFAULT_SCHEME ;
134115 }
135116
136- $ params = $ add + array (
137- 'username ' => $ username ,
138- 'password ' => $ password ,
139- 'endpoint ' => $ baseURL ,
140- 'tenantid ' => $ tenant ,
117+ $ params += [
118+ 'username ' => self :: $ settings [ ' openstack.identity. username' ] ,
119+ 'password ' => self :: $ settings [ ' openstack.identity. password' ] ,
120+ 'endpoint ' => self :: $ settings [ ' openstack.identity.url ' ] ,
121+ 'tenantid ' => self :: $ settings [ ' openstack.identity.tenantId ' ] ,
141122 'content_type ' => self ::FTYPE ,
142123 'transport_client ' => $ this ->getTransportClient (),
143- );
144- $ cxt = array ($ scheme => $ params );
145-
146- return stream_context_create ($ cxt );
124+ ];
147125
126+ return stream_context_create ([
127+ $ scheme => $ params
128+ ]);
148129 }
149130
150131 /**
@@ -162,7 +143,7 @@ protected function addBootstrapConfig()
162143 'password ' => self ::$ settings ['openstack.identity.password ' ],
163144 'endpoint ' => self ::$ settings ['openstack.identity.url ' ],
164145 'tenantid ' => self ::$ settings ['openstack.identity.tenantId ' ],
165- 'token ' => $ this ->objectStore ()->token (),
146+ 'token ' => $ this ->objectStore ()->token (),
166147 'swift_endpoint ' => $ this ->objectStore ()->url (),
167148 );
168149 \OpenStack \Bootstrap::setConfiguration ($ opts );
0 commit comments