Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1415 from fauvel/issue-1415
Browse files Browse the repository at this point in the history
 Type `XXX` not configured for class `CM_Mail`
  • Loading branch information
fauvel committed Sep 22, 2014
2 parents 4e965f2 + 73a133c commit e8760a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions library/CM/Action/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ class CM_Action_Email extends CM_Action_Abstract {
public function __construct($verbName, $actor, $typeEmail) {
parent::__construct($verbName, $actor);
$typeEmail = (int) $typeEmail;
$className = CM_Mail::_getClassName($typeEmail);
$this->_nameEmail = ucwords(CM_Util::uncamelize(str_replace('_', '', preg_replace('#\\A[^_]++_[^_]++_#', '', $className)), ' '));
try {
$className = CM_Mail::_getClassName($typeEmail);
$this->_nameEmail = ucwords(CM_Util::uncamelize(str_replace('_', '', preg_replace('#\\A[^_]++_[^_]++_#', '', $className)), ' '));
} catch (CM_Class_Exception_TypeNotConfiguredException $exception) {
$exception->setSeverity(CM_Exception::WARN);
CM_Bootloader::getInstance()->getExceptionHandler()->handleException($exception);
$this->_nameEmail = (string) $typeEmail;
}
}

public function getLabel() {
Expand Down
7 changes: 7 additions & 0 deletions tests/library/CM/Action/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ public function testGetLabel() {
$action = new CM_Action_Email(CM_Action_Abstract::VIEW, $actor, $typeEmail);
$this->assertSame('Email View Welcome', $action->getLabel());
}

public function testGetLabel_typeNotConfigured() {
$actor = CMTest_TH::createUser();
$typeEmail = mt_rand();
$action = new CM_Action_Email(CM_Action_Abstract::VIEW, $actor, $typeEmail);
$this->assertSame('Email View ' . $typeEmail, $action->getLabel());
}
}

0 comments on commit e8760a7

Please sign in to comment.