Skip to content
Permalink
Browse files

Add `Email::configuredTransport()` to enumerate transport key names.

This mirrors the ability to call `::configured()` on any class that uses the StaticConfigTrait or `array_keys(::config())` (with no arguments) on any class that uses the InstanceConfigTrait.

Filling this shortcoming is important because the key names (normally defined in config/app.php) are removed from Configure when they are `Configure::consume()`d in config/bootstrap.php. There is no other way to determine what transports the Email class knows about without this.
  • Loading branch information...
beporter committed Jul 7, 2015
1 parent f0d3a7a commit 9a0625261d40f24060b7de1ca7eebaec4dffb30c
Showing with 32 additions and 3 deletions.
  1. +10 −0 src/Network/Email/Email.php
  2. +22 −3 tests/TestCase/Network/Email/EmailTest.php
@@ -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.
*
@@ -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);
}
/**
@@ -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
*

0 comments on commit 9a06252

Please sign in to comment.
You can’t perform that action at this time.