PageRenderTime 122ms CodeModel.GetById 46ms app.highlight 5ms RepoModel.GetById 69ms app.codeStats 0ms

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

https://bitbucket.org/mstowe/zurmo
PHP | 86 lines | 52 code | 6 blank | 28 comment | 0 complexity | c057939a44f2430eeb463bead15591e2 MD5 | raw file
 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
27    class OpportunitiesChartWalkthroughTest extends ZurmoWalkthroughBaseTest
28    {
29            public static function setUpBeforeClass()
30        {
31            parent::setUpBeforeClass();
32            SecurityTestHelper::createSuperAdmin();
33            $super = User::getByUsername('super');
34            Yii::app()->user->userModel = $super;
35
36            //Setup test data owned by the super user.
37            $account = AccountTestHelper::createAccountByNameForOwner        ('superAccount',  $super);
38            AccountTestHelper::createAccountByNameForOwner                   ('superAccount2', $super);
39            ContactTestHelper::createContactWithAccountByNameForOwner        ('superContact',  $super, $account);
40            ContactTestHelper::createContactWithAccountByNameForOwner        ('superContact2', $super, $account);
41            OpportunityTestHelper::createOpportunityStagesIfDoesNotExist     ();
42            OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp',      $super, $account);
43            OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp2',     $super, $account);
44            OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp3',     $super, $account);
45            OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp4',     $super, $account);
46            //Setup default dashboard.
47            Dashboard::getByLayoutIdAndUser                                  (Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
48        }
49
50        public function testCharts()
51        {
52            $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
53
54            //Test OpportunitiesByStage
55            $portlet = new Portlet();
56            $portlet->column    = 1;
57            $portlet->position  = 1;
58            $portlet->layoutId  = 'TestLayout';
59            $portlet->collapsed = false;
60            $portlet->viewType  = 'OpportunitiesByStageChart';
61            $portlet->user      = $super;
62            $this->assertTrue($portlet->save());
63            $this->setGetArray(array('chartLibraryName' => 'Fusion', 'portletId' => $portlet->id));
64            $this->resetPostArray();
65            $content = $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/makeChartXML');
66            $this->assertFalse(strpos($content, '<graph') === false);
67            $this->assertEquals(0, strpos($content, chr(239) . chr(187) . chr(191) . '<?xml version="1.0" encoding="UTF-8"?><graph'));
68
69            //Test OpportunitiesBySource
70            $portlet = new Portlet();
71            $portlet->column    = 1;
72            $portlet->position  = 2;
73            $portlet->layoutId  = 'TestLayout';
74            $portlet->collapsed = false;
75            $portlet->viewType  = 'OpportunitiesByStageChart';
76            $portlet->user      = $super;
77            $this->assertTrue($portlet->save());
78            $this->setGetArray(array('chartLibraryName' => 'Fusion', 'portletId' => $portlet->id));
79            $this->resetPostArray();
80            $content = $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/makeChartXML');
81            $this->assertFalse(strpos($content, '<graph') === false);
82            $this->assertEquals(0, strpos($content, chr(239) . chr(187) . chr(191) . '<?xml version="1.0" encoding="UTF-8"?><graph'));
83        }
84    }
85?>
86