Skip to content

Commit

Permalink
Test to prove tighten#81 was actually fixed!
Browse files Browse the repository at this point in the history
  • Loading branch information
FatBoyXPC committed Nov 4, 2017
1 parent ade59e0 commit 8be0b8d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
"tests/TestCase.php",
"tests/AppStub.php"
]
}
}
43 changes: 43 additions & 0 deletions tests/AppStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

class AppStub extends \Illuminate\Foundation\Application implements \ArrayAccess
{
private $foo;
private $mailer;
protected $attributes = [];

public function setAttributes($attributes)
{
$this->attributes = $attributes;
}

public function version()
{
return 5.4;
}

public function instance($key, $instance)
{
$this->attributes[$key] = $instance;
}

public function offsetExists($offset)
{
return isset($this->attributes[$offset]);
}

public function offsetGet($key)
{
return $this->attributes[$key];
}

public function offsetSet($key, $value)
{
$this->attributes[$key] = $value;
}

public function offsetUnset($key)
{
unset($this->attributes[$key]);
}
}
41 changes: 41 additions & 0 deletions tests/MailFacadeIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Mail;
use MailThief\Facades\MailThief;
use MailThief\Testing\InteractsWithMail;
use MailThief\MailThiefFiveFourCompatible;

class MailFacadeIntegrationTest extends TestCase
{
use InteractsWithMail;

public function setUp()
{
$app = new AppStub;
$app->setAttributes([
MailThiefFiveFourCompatible::class => $this->getMailThief(),
]);

Facade::setFacadeApplication($app);

parent::setUp();
}

public function test_previously_set_instance_of_mailthief_doesnt_change()
{
Mail::send('example-view', [], function ($m) {
$m->to('[email protected]');
});

$this->seeMessageFor('[email protected]');

MailThief::swap($this->getMailThief());

Mail::send('example-view', [], function ($m) {
$m->to('[email protected]');
});

$this->seeMessageFor('[email protected]');
}
}

0 comments on commit 8be0b8d

Please sign in to comment.