Esempio n. 1
0
 public function testGetImage()
 {
     TestingAuxLib::loadControllerMock();
     $image = $this->media('bg');
     $this->assertTrue($image->fileExists());
     $this->assertTrue($image->isImage());
     $expected = '<img class="attachment-img" src="' . $image->getPublicUrl() . '" alt="" />';
     $imageTag = $image->getImage();
     $this->assertEquals($expected, $imageTag);
 }
Esempio n. 2
0
 public function testPropertySetters()
 {
     TestingAuxLib::loadControllerMock();
     $profile = $this->profiles('adminProfile');
     $widgetLayout = $profile->profileWidgetLayout;
     $widgetClass = 'ContactsGridViewProfileWidget';
     $widgetProps = $widgetLayout[$widgetClass];
     $newWidgetProps = $widgetProps;
     $newWidgetProps['label'] = 'newLabel';
     $widgetClass::setJSONProperties($profile, $newWidgetProps, 'profile', '');
     $profile->refresh();
     $widgetLayout = $profile->profileWidgetLayout;
     $widgetProps = $widgetLayout[$widgetClass];
     $this->assertEquals($newWidgetProps, $widgetProps);
     $widgetClass::setJSONProperty($profile, 'label', 'newLabel2', 'profile', '');
     $newWidgetProps['label'] = 'newLabel2';
     $profile->refresh();
     $widgetLayout = $profile->profileWidgetLayout;
     $widgetProps = $widgetLayout[$widgetClass];
     $this->assertEquals($newWidgetProps, $widgetProps);
     $this->obStart();
     $instance = self::createWidget($widgetClass . '_', $profile);
     $this->obEndClean();
     $instance->setWidgetProperty('label', 'newLabel3');
     $newWidgetProps['label'] = 'newLabel3';
     $profile->refresh();
     $widgetLayout = $profile->profileWidgetLayout;
     $widgetProps = $widgetLayout[$widgetClass];
     $this->assertEquals($newWidgetProps, $widgetProps);
     $instance->setWidgetProperties(array('label' => 'newLabel4'));
     $newWidgetProps['label'] = 'newLabel4';
     $profile->refresh();
     $widgetLayout = $profile->profileWidgetLayout;
     $widgetProps = $widgetLayout[$widgetClass];
     $this->assertEquals($newWidgetProps, $widgetProps);
 }
 public function testGetVisibleRelatedX2Models()
 {
     TestingAuxLib::loadControllerMock();
     TestingAuxLib::suLogin('testUser2');
     $contact = $this->contact('testAnyone');
     $otherContact = $this->contact('testUser');
     $this->assertFalse($contact->relationships->hasRelationship($otherContact));
     $contact->relationships->createRelationship($otherContact);
     $this->assertTrue($contact->relationships->hasRelationship($otherContact));
     $visibleRelatedModels = $contact->relationships->getVisibleRelatedX2Models(true);
     $this->assertEquals(1, count($visibleRelatedModels));
     $this->assertInstanceOf(get_class($otherContact), $visibleRelatedModels[0]);
     $this->assertEquals($otherContact->id, $visibleRelatedModels[0]->id);
     $otherContact->visibility = 0;
     $otherContact->assignedTo = 'test';
     $this->assertSaves($otherContact);
     Yii::app()->params->isAdmin = false;
     $visibleRelatedModels = $contact->relationships->getVisibleRelatedX2Models();
     $this->assertEquals(1, count($visibleRelatedModels));
     $this->assertInstanceOf(get_class($otherContact), $visibleRelatedModels[0]);
     $this->assertEquals($otherContact->id, $visibleRelatedModels[0]->id);
     $this->assertEmpty($contact->relationships->getVisibleRelatedX2Models(true));
 }
Esempio n. 4
0
 public function setUp()
 {
     TestingAuxLib::loadControllerMock();
     return parent::setUp();
 }
 /**
  * Cause line break replacement to fail and ensure that exception is thrown
  */
 public function testUnsubTokenReplacementError()
 {
     // error can't be triggered using current method of reducing the backtrack_limit and
     // recursion_limit since there's a call to createExternalUrl directly preceeding the
     // code which does the token replacement
     $this->markTestSkipped();
     $this->setExpectedException('StringUtilException', '', StringUtilException::PREG_REPLACE_ERROR);
     ini_set('pcre.backtrack_limit', '0');
     ini_set('pcre.recursion_limit', '0');
     TestingAuxLib::loadControllerMock('localhost', '/index-test.php');
     $cmb = $this->instantiate();
     $contact = $this->contacts('testUser_unsent');
     list($subject, $message, $uniqueId) = $cmb->prepareEmail($this->campaign('testUser'), $contact, false);
 }