Skip to content

Commit

Permalink
Merge pull request #6969 from beporter/enumerate-email-transports
Browse files Browse the repository at this point in the history
Add `Email::configuredTransport()` to enumerate transport key names.
  • Loading branch information
markstory committed Jul 8, 2015
2 parents 2499227 + 9a06252 commit 97c3dcc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Network/Email/Email.php
Expand Up @@ -1240,6 +1240,16 @@ public static function configTransport($key, $config = null)
static::$_transportConfig[$key] = $config;
}

/**
* Returns an array containing the named transport configurations
*
* @return array Array of configurations.
*/
public static function configuredTransport()
{
return array_keys(static::$_transportConfig);
}

/**
* Delete transport configuration.
*
Expand Down
25 changes: 22 additions & 3 deletions tests/TestCase/Network/Email/EmailTest.php
Expand Up @@ -100,9 +100,12 @@ public function setUp()
parent::setUp();
$this->CakeEmail = new TestEmail();

Email::configTransport('debug', [
'className' => 'Debug'
]);
$this->transports = [
'debug' => [
'className' => 'Debug'
]
];
Email::configTransport($this->transports);
}

/**
Expand Down Expand Up @@ -881,6 +884,22 @@ public function testConfigTransportInstance()
$this->assertEquals(['className' => $instance], Email::configTransport('debug'));
}

/**
* Test enumerating all transport configurations
*
* @return void
*/
public function testConfiguredTransport()
{
$result = Email::configuredTransport();
$this->assertInternalType('array', $result, 'Should have config keys');
$this->assertEquals(
array_keys($this->transports),
$result,
'Loaded transports should be present in enumeration.'
);
}

/**
* Test dropping a transport configuration
*
Expand Down

0 comments on commit 97c3dcc

Please sign in to comment.