public function ImageTest::testSave in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::testSave()
Tests \Drupal\Core\Image\Image::save().
File
- core/
tests/ Drupal/ Tests/ Core/ Image/ ImageTest.php, line 205
Class
- ImageTest
- Tests the image class.
Namespace
Drupal\Tests\Core\ImageCode
public function testSave() {
$this
->getTestImage();
// This will fail if save() method isn't called on the toolkit.
$toolkit = $this
->getToolkitMock();
$toolkit
->expects($this
->once())
->method('save')
->will($this
->returnValue(TRUE));
$image = $this
->getMockBuilder('Drupal\\Core\\Image\\Image')
->setMethods([
'chmod',
])
->setConstructorArgs([
$toolkit,
$this->image
->getSource(),
])
->getMock();
$file_system = $this
->prophesize(FileSystemInterface::class);
$file_system
->chmod($this->image
->getSource())
->willReturn(TRUE);
$container = $this
->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')
->setMethods([
'get',
])
->getMock();
$container
->expects($this
->once())
->method('get')
->with('file_system')
->willReturn($file_system
->reveal());
\Drupal::setContainer($container);
$image
->save();
}