public function testUploadData() { $content = "testUploadFile\nline1\nline2\n"; $adapter = $this->getMockBuilder('Zend\\Http\\Client\\Adapter\\Test')->setMethods(array('write'))->getMock(); $adapter->expects($this->once())->method('write')->with('POST', 'http://example.net/server', '1.1', $this->callback(function ($headers) { return $headers['User-Agent'] == 'Braintacle_local_upload' and $headers['Content-Type'] == 'application/x-compress'; }), $content); $uploader = new InventoryUploader('http://example.net/server', $adapter); $uploader->uploadData($content); $this->assertTrue(\PHPUnit_Framework_Assert::readAttribute($adapter, 'config')['strictredirects']); }
public function testUploadData() { $content = "testUploadFile\nline1\nline2\n"; $adapter = $this->getMockBuilder('Zend\\Http\\Client\\Adapter\\Test')->setMethods(array('write'))->getMock(); $adapter->expects($this->once())->method('write')->with('POST', 'http://example.net/server', '1.1', $this->callback(function ($headers) { return $headers['User-Agent'] == 'Braintacle_local_upload' and $headers['Content-Type'] == 'application/x-compress'; }), $content); $uploader = new InventoryUploader('http://example.net/server', $adapter); $uploader->uploadData($content); // No public method available to test "strictredirects" option - use reflection $reflectionClass = new \ReflectionClass($adapter); $reflectionProperty = $reflectionClass->getProperty('config'); $reflectionProperty->setAccessible(true); $this->assertTrue($reflectionProperty->getValue($adapter)['strictredirects']); }