Skip to content

Commit

Permalink
Move TestMailer to TestApp
Browse files Browse the repository at this point in the history
  • Loading branch information
jadb committed Apr 19, 2015
1 parent 4e4d9a3 commit 0e00baf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
23 changes: 8 additions & 15 deletions tests/TestCase/Mailer/MailerTest.php
Expand Up @@ -15,14 +15,7 @@
use Cake\Mailer\Email;
use Cake\Mailer\Mailer;
use Cake\TestSuite\TestCase;

class TestMailer extends Mailer
{
public function getEmailForAssertion()
{
return $this->_email;
}
}
use TestApp\Mailer\TestMailer;

class MailerTest extends TestCase
{
Expand Down Expand Up @@ -57,7 +50,7 @@ public function testGetName()
public function testLayout()
{
$result = (new TestMailer())->layout('foo');
$this->assertInstanceOf('Cake\Test\TestCase\Mailer\TestMailer', $result);
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $result);
$this->assertEquals('foo', $result->layout);
}

Expand All @@ -68,21 +61,21 @@ public function testProxies()
->method('setHeaders')
->with([]);
$result = (new TestMailer($email))->setHeaders([]);
$this->assertInstanceOf('Cake\Test\TestCase\Mailer\TestMailer', $result);
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $result);

$email = $this->getMockForEmail('addHeaders');
$email->expects($this->once())
->method('addHeaders')
->with([]);
$result = (new TestMailer($email))->addHeaders([]);
$this->assertInstanceOf('Cake\Test\TestCase\Mailer\TestMailer', $result);
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $result);

$email = $this->getMockForEmail('attachments');
$email->expects($this->once())
->method('attachments')
->with([]);
$result = (new TestMailer($email))->attachments([]);
$this->assertInstanceOf('Cake\Test\TestCase\Mailer\TestMailer', $result);
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $result);
}

public function testSet()
Expand All @@ -92,14 +85,14 @@ public function testSet()
->method('viewVars')
->with(['key' => 'value']);
$result = (new TestMailer($email))->set('key', 'value');
$this->assertInstanceOf('Cake\Test\TestCase\Mailer\TestMailer', $result);
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $result);

$email = $this->getMockForEmail('viewVars');
$email->expects($this->once())
->method('viewVars')
->with(['key' => 'value']);
$result = (new TestMailer($email))->set(['key' => 'value']);
$this->assertInstanceOf('Cake\Test\TestCase\Mailer\TestMailer', $result);
$this->assertInstanceOf('TestApp\Mailer\TestMailer', $result);
}

public function testSend()
Expand All @@ -109,7 +102,7 @@ public function testSend()
->method('send')
->will($this->returnValue([]));

$mailer = $this->getMock('Cake\Test\TestCase\Mailer\TestMailer', ['test'], [$email]);
$mailer = $this->getMock('TestApp\Mailer\TestMailer', ['test'], [$email]);
$mailer->expects($this->once())
->method('test')
->with('foo', 'bar');
Expand Down
32 changes: 32 additions & 0 deletions tests/test_app/TestApp/Mailer/TestMailer.php
@@ -0,0 +1,32 @@
<?php
/**
* Test Suite Test App Logging stream class.
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @since 1.3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace TestApp\Mailer;

use Cake\Mailer\Mailer;

/**
* Test Suite Test App Mailer class.
*
*/
class TestMailer extends Mailer
{

public function getEmailForAssertion()
{
return $this->_email;
}
}

0 comments on commit 0e00baf

Please sign in to comment.