File tree 2 files changed +46
-0
lines changed
lib/OpenCloud/ObjectStore
tests/OpenCloud/Tests/ObjectStore
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ public function listContainers(array $filter = array())
92
92
*/
93
93
public function getContainer ($ data = null )
94
94
{
95
+ if (is_string ($ data ) || is_numeric ($ data )) {
96
+ $ this ->checkContainerName ($ data );
97
+ }
98
+
95
99
return new Container ($ this , $ data );
96
100
}
97
101
Original file line number Diff line number Diff line change @@ -99,6 +99,48 @@ public function test_Bad_Container_Name_Long()
99
99
$ this ->service ->createContainer (str_repeat ('a ' , Service::MAX_CONTAINER_NAME_LENGTH + 1 ));
100
100
}
101
101
102
+ /**
103
+ * @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
104
+ */
105
+ public function test_Get_Bad_Container_Name_Empty ()
106
+ {
107
+ $ this ->service ->getContainer ('' );
108
+ }
109
+
110
+ /**
111
+ * @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
112
+ */
113
+ public function test_Get_Bad_Container_Name_Slashes ()
114
+ {
115
+ $ this ->service ->getContainer ('foo/bar ' );
116
+ }
117
+
118
+ /**
119
+ * @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
120
+ */
121
+ public function test_Get_Bad_Container_Name_Long ()
122
+ {
123
+ $ this ->service ->getContainer (str_repeat ('a ' , Service::MAX_CONTAINER_NAME_LENGTH + 1 ));
124
+ }
125
+
126
+ /**
127
+ * @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
128
+ */
129
+ public function test_Get_Bad_Container_Name_Float ()
130
+ {
131
+ $ this ->service ->getContainer (4.5 );
132
+ }
133
+
134
+ public function test_Get_Container_String ()
135
+ {
136
+ $ this ->assertInstanceOf ('OpenCloud\ObjectStore\Resource\Container ' , $ this ->service ->getContainer ('foo ' ));
137
+ }
138
+
139
+ public function test_Get_Container_Integer ()
140
+ {
141
+ $ this ->assertInstanceOf ('OpenCloud\ObjectStore\Resource\Container ' , $ this ->service ->getContainer (1 ));
142
+ }
143
+
102
144
public function test_Bulk_Extract ()
103
145
{
104
146
$ response = $ this ->service ->bulkExtract ('fooBarContainer ' , 'CONTENT ' , UrlType::TAR );
You can’t perform that action at this time.
0 commit comments