Skip to content

Commit 3b6b06f

Browse files
committed
Tests
1 parent 78c5cba commit 3b6b06f

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
namespace PhpOffice\PhpWord\Tests\Element;
3+
4+
use PhpOffice\PhpWord\PhpWord;
5+
use PhpOffice\PhpWord\Style\Image;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class SvgImageTest extends TestCase
9+
{
10+
private string $svgPath;
11+
12+
protected function setUp(): void
13+
{
14+
$this->svgPath = __DIR__ . '/../_files/images/sample.svg';
15+
if (!file_exists($this->svgPath)) {
16+
$this->markTestSkipped('SVG file not found: ' . $this->svgPath);
17+
}
18+
}
19+
20+
public function testAddSvgImageWithoutStyles()
21+
{
22+
$phpWord = new PhpWord();
23+
$section = $phpWord->addSection();
24+
$image = $section->addImage($this->svgPath);
25+
26+
$this->assertEquals($this->svgPath, $image->getSource());
27+
$this->assertEquals('image/svg+xml', $image->getImageType());
28+
}
29+
30+
public function testAddSvgImageWithStyles()
31+
{
32+
$phpWord = new PhpWord();
33+
$section = $phpWord->addSection();
34+
$options = [
35+
'width' => 200,
36+
'height' => 200,
37+
'wrappingStyle' => Image::WRAPPING_STYLE_BEHIND,
38+
];
39+
40+
$image = $section->addImage($this->svgPath, $options);
41+
42+
$this->assertEquals(200, $image->getStyle()->getWidth());
43+
$this->assertEquals(200, $image->getStyle()->getHeight());
44+
$this->assertEquals(Image::WRAPPING_STYLE_BEHIND, $image->getStyle()->getWrappingStyle());
45+
}
46+
}
Lines changed: 96 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)