PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/app/protected/modules/opportunities/tests/unit/walkthrough/OpportunitiesChartWalkthroughTest.php

https://bitbucket.org/Amit_Ashckenazi/unmatched-archives
PHP | 85 lines | 52 code | 5 blank | 28 comment | 0 complexity | 840293fa5fe49aa370c18e0d65b27ee5 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, LGPL-3.0, LGPL-2.1, BSD-2-Clause
  1. <?php
  2. /*********************************************************************************
  3. * Zurmo is a customer relationship management program developed by
  4. * Zurmo, Inc. Copyright (C) 2012 Zurmo Inc.
  5. *
  6. * Zurmo is free software; you can redistribute it and/or modify it under
  7. * the terms of the GNU General Public License version 3 as published by the
  8. * Free Software Foundation with the addition of the following permission added
  9. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  10. * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
  11. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  12. *
  13. * Zurmo is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  20. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301 USA.
  22. *
  23. * You can contact Zurmo, Inc. with a mailing address at 113 McHenry Road Suite 207,
  24. * Buffalo Grove, IL 60089, USA. or at email address contact@zurmo.com.
  25. ********************************************************************************/
  26. class OpportunitiesChartWalkthroughTest extends ZurmoWalkthroughBaseTest
  27. {
  28. public static function setUpBeforeClass()
  29. {
  30. parent::setUpBeforeClass();
  31. SecurityTestHelper::createSuperAdmin();
  32. $super = User::getByUsername('super');
  33. Yii::app()->user->userModel = $super;
  34. //Setup test data owned by the super user.
  35. $account = AccountTestHelper::createAccountByNameForOwner ('superAccount', $super);
  36. AccountTestHelper::createAccountByNameForOwner ('superAccount2', $super);
  37. ContactTestHelper::createContactWithAccountByNameForOwner ('superContact', $super, $account);
  38. ContactTestHelper::createContactWithAccountByNameForOwner ('superContact2', $super, $account);
  39. OpportunityTestHelper::createOpportunityStagesIfDoesNotExist ();
  40. OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp', $super, $account);
  41. OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp2', $super, $account);
  42. OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp3', $super, $account);
  43. OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp4', $super, $account);
  44. //Setup default dashboard.
  45. Dashboard::getByLayoutIdAndUser (Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
  46. }
  47. public function testCharts()
  48. {
  49. $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
  50. //Test OpportunitiesByStage
  51. $portlet = new Portlet();
  52. $portlet->column = 1;
  53. $portlet->position = 1;
  54. $portlet->layoutId = 'TestLayout';
  55. $portlet->collapsed = false;
  56. $portlet->viewType = 'OpportunitiesByStageChart';
  57. $portlet->user = $super;
  58. $this->assertTrue($portlet->save());
  59. $this->setGetArray(array('chartLibraryName' => 'Fusion', 'portletId' => $portlet->id));
  60. $this->resetPostArray();
  61. $content = $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/makeChartXML');
  62. $this->assertFalse(strpos($content, '<graph') === false);
  63. $this->assertEquals(0, strpos($content, chr(239) . chr(187) . chr(191) . '<?xml version="1.0" encoding="UTF-8"?><graph'));
  64. //Test OpportunitiesBySource
  65. $portlet = new Portlet();
  66. $portlet->column = 1;
  67. $portlet->position = 2;
  68. $portlet->layoutId = 'TestLayout';
  69. $portlet->collapsed = false;
  70. $portlet->viewType = 'OpportunitiesByStageChart';
  71. $portlet->user = $super;
  72. $this->assertTrue($portlet->save());
  73. $this->setGetArray(array('chartLibraryName' => 'Fusion', 'portletId' => $portlet->id));
  74. $this->resetPostArray();
  75. $content = $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/makeChartXML');
  76. $this->assertFalse(strpos($content, '<graph') === false);
  77. $this->assertEquals(0, strpos($content, chr(239) . chr(187) . chr(191) . '<?xml version="1.0" encoding="UTF-8"?><graph'));
  78. }
  79. }
  80. ?>