CommentA 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace PhpPresentation\Tests\Writer\PowerPoint2007;
  3. use PhpOffice\PhpPresentation\Shape\Comment;
  4. use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
  5. class CommentAuthorsTest extends PhpPresentationTestCase
  6. {
  7. protected $writerName = 'PowerPoint2007';
  8. public function testComments()
  9. {
  10. $expectedElement = '/p:cmAuthorLst/p:cmAuthor';
  11. $expectedName = 'Name';
  12. $expectedInitials = 'Initials';
  13. $oAuthor = new Comment\Author();
  14. $oAuthor->setName($expectedName);
  15. $oAuthor->setInitials($expectedInitials);
  16. $oComment = new Comment();
  17. $oComment->setAuthor($oAuthor);
  18. $this->oPresentation->getActiveSlide()->addShape($oComment);
  19. $this->assertZipFileExists('ppt/commentAuthors.xml');
  20. $this->assertZipXmlElementExists('ppt/commentAuthors.xml', $expectedElement);
  21. $this->assertZipXmlAttributeEquals('ppt/commentAuthors.xml', $expectedElement, 'id', 0);
  22. $this->assertZipXmlAttributeEquals('ppt/commentAuthors.xml', $expectedElement, 'name', $expectedName);
  23. $this->assertZipXmlAttributeEquals('ppt/commentAuthors.xml', $expectedElement, 'initials', $expectedInitials);
  24. }
  25. public function testWithoutComment()
  26. {
  27. $this->assertZipFileNotExists('ppt/commentAuthors.xml');
  28. }
  29. public function testWithoutCommentAuthor()
  30. {
  31. $oComment = new Comment();
  32. $this->oPresentation->getActiveSlide()->addShape($oComment);
  33. $this->assertZipFileNotExists('ppt/commentAuthors.xml');
  34. }
  35. public function testWithSameAuthor()
  36. {
  37. $expectedElement = '/p:cmAuthorLst/p:cmAuthor';
  38. $oAuthor = new Comment\Author();
  39. $oComment1 = new Comment();
  40. $oComment1->setAuthor($oAuthor);
  41. $this->oPresentation->getActiveSlide()->addShape($oComment1);
  42. $oComment2 = new Comment();
  43. $oComment2->setAuthor($oAuthor);
  44. $this->oPresentation->getActiveSlide()->addShape($oComment2);
  45. $this->assertZipFileExists('ppt/commentAuthors.xml');
  46. $this->assertZipXmlElementExists('ppt/commentAuthors.xml', $expectedElement);
  47. $this->assertZipXmlElementCount('ppt/commentAuthors.xml', $expectedElement, 1);
  48. }
  49. }