LiveDocxTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_LiveDocx
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: $
  21. */
  22. require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
  23. if (!defined('PHPUnit_MAIN_METHOD')) {
  24. define('PHPUnit_MAIN_METHOD', 'Zend_Service_LiveDocx_LiveDocxTest::main');
  25. }
  26. require_once 'Zend/Service/LiveDocx/MailMerge.php';
  27. /**
  28. * Zend_Service_LiveDocx test case
  29. *
  30. * @category Zend
  31. * @package Zend_Service_LiveDocx
  32. * @subpackage UnitTests
  33. * @group Zend_Service
  34. * @group Zend_Service_LiveDocx
  35. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. * @version $Id: $
  38. */
  39. class Zend_Service_LiveDocX_LiveDocxTest extends PHPUnit_Framework_TestCase
  40. {
  41. public $phpLiveDocx;
  42. public static function main()
  43. {
  44. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  45. $result = PHPUnit_TextUI_TestRunner::run($suite);
  46. }
  47. public function setUp()
  48. {
  49. if (!constant('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME')
  50. || !constant('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD')
  51. ) {
  52. $this->markTestSkipped('LiveDocx tests disabled');
  53. return;
  54. }
  55. $this->phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
  56. $this->phpLiveDocx->setUsername(TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  57. ->setPassword(TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  58. foreach ($this->phpLiveDocx->listTemplates() as $template) {
  59. $this->phpLiveDocx->deleteTemplate($template['filename']);
  60. }
  61. }
  62. public function tearDown ()
  63. {
  64. if (isset($this->phpLiveDocx)) {
  65. foreach ($this->phpLiveDocx->listTemplates() as $template) {
  66. $this->phpLiveDocx->deleteTemplate($template['filename']);
  67. }
  68. unset($this->phpLiveDocx);
  69. }
  70. }
  71. public function testGetFormat ()
  72. {
  73. $this->assertEquals('', $this->phpLiveDocx->getFormat('document'));
  74. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document.doc'));
  75. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document-123.doc'));
  76. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document123.doc'));
  77. $this->assertEquals('doc', $this->phpLiveDocx->getFormat('document.123.doc'));
  78. }
  79. public function testGetVersion ()
  80. {
  81. $expectedResults = '2.0';
  82. $this->assertEquals($expectedResults, $this->phpLiveDocx->getVersion());
  83. }
  84. }
  85. if (PHPUnit_MAIN_METHOD == 'Zend_Service_LiveDocx_LiveDocxTest::main') {
  86. Zend_Service_LiveDocx_LiveDocxTest::main();
  87. }