Skip to content

Commit 362246d

Browse files
committed
fix: unity tests
1 parent 0b40383 commit 362246d

2 files changed

Lines changed: 38 additions & 28 deletions

File tree

src/Mail/Envelop.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Bow\Mail;
66

7-
use Bow\Mail\Exception\MailException;
7+
use Bow\View\View;
88
use Bow\Support\Str;
99
use InvalidArgumentException;
10+
use Bow\Mail\Exception\MailException;
1011

1112
class Envelop
1213
{
@@ -486,7 +487,7 @@ public function fromIsDefined(): bool
486487
*/
487488
public function view(string $view, array $data = []): Envelop
488489
{
489-
$this->message(view($view, $data)->getContent());
490+
$this->message(View::parse($view, $data)->getContent());
490491

491492
return $this;
492493
}

tests/Queue/MessagingQueueTest.php

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,49 @@
33
namespace Bow\Tests\Queue;
44

55
use Bow\Database\Barry\Model;
6+
use Bow\Mail\MailConfiguration;
7+
use Bow\View\ViewConfiguration;
8+
use PHPUnit\Framework\TestCase;
9+
use Bow\Cache\CacheConfiguration;
10+
use Bow\Queue\QueueConfiguration;
11+
use Bow\Configuration\EnvConfiguration;
612
use Bow\Messaging\MessagingQueueProducer;
7-
use Bow\Queue\Connection as QueueConnection;
13+
use Bow\Configuration\LoggerConfiguration;
14+
use Bow\Tests\Config\TestingConfiguration;
815
use Bow\Tests\Messaging\Stubs\TestMessage;
9-
use Bow\Tests\Messaging\Stubs\TestNotifiableModel;
16+
use Bow\Queue\Connection as QueueConnection;
1017
use PHPUnit\Framework\MockObject\MockObject;
11-
use PHPUnit\Framework\TestCase;
18+
use Bow\Tests\Messaging\Stubs\TestNotifiableModel;
1219

1320
class MessagingTest extends TestCase
1421
{
15-
private static QueueConnection $queueConnection;
22+
private static QueueConnection $connection;
1623
private MockObject|Model $context;
1724
private MockObject|TestMessage $message;
1825

1926
public static function setUpBeforeClass(): void
2027
{
21-
parent::setUpBeforeClass();
22-
23-
// Initialize queue connection
24-
static::$queueConnection = new QueueConnection([
25-
'default' => 'sync',
26-
'connections' => [
27-
'sync' => [
28-
'driver' => 'sync'
29-
]
30-
]
28+
TestingConfiguration::withConfigurations([
29+
CacheConfiguration::class,
30+
QueueConfiguration::class,
31+
EnvConfiguration::class,
32+
LoggerConfiguration::class,
33+
MailConfiguration::class,
34+
ViewConfiguration::class,
3135
]);
36+
37+
$config = TestingConfiguration::getConfig();
38+
$config->boot();
39+
40+
static::$connection = new QueueConnection($config["queue"]);
41+
}
42+
43+
protected function setUp(): void
44+
{
45+
parent::setUp();
46+
47+
$this->context = $this->createMock(TestNotifiableModel::class);
48+
$this->message = $this->createMock(TestMessage::class);
3249
}
3350

3451
public function test_can_send_message_synchronously(): void
@@ -48,7 +65,7 @@ public function test_can_send_message_to_queue(): void
4865
$this->assertInstanceOf(MessagingQueueProducer::class, $producer);
4966

5067
// Push to queue and verify
51-
static::$queueConnection->getAdapter()->push($producer);
68+
static::$connection->setConnection("beanstalkd")->getAdapter()->push($producer);
5269

5370
$this->context->setMessageQueue($this->message);
5471
}
@@ -62,7 +79,7 @@ public function test_can_send_message_to_specific_queue(): void
6279
$this->assertInstanceOf(MessagingQueueProducer::class, $producer);
6380

6481
// Push to specific queue and verify
65-
$adapter = static::$queueConnection->getAdapter();
82+
$adapter = static::$connection->setConnection("beanstalkd")->getAdapter();
6683
$adapter->setQueue($queue);
6784
$adapter->push($producer);
6885

@@ -78,7 +95,7 @@ public function test_can_send_message_with_delay(): void
7895
$this->assertInstanceOf(MessagingQueueProducer::class, $producer);
7996

8097
// Push to queue and verify
81-
$adapter = static::$queueConnection->getAdapter();
98+
$adapter = static::$connection->setConnection("beanstalkd")->getAdapter();
8299
$adapter->setSleep($delay);
83100
$adapter->push($producer);
84101

@@ -95,19 +112,11 @@ public function test_can_send_message_with_delay_on_specific_queue(): void
95112
$this->assertInstanceOf(MessagingQueueProducer::class, $producer);
96113

97114
// Push to specific queue with delay and verify
98-
$adapter = static::$queueConnection->getAdapter();
115+
$adapter = static::$connection->setConnection("beanstalkd")->getAdapter();
99116
$adapter->setQueue($queue);
100117
$adapter->setSleep($delay);
101118
$adapter->push($producer);
102119

103120
$this->context->sendMessageLaterOn($delay, $queue, $this->message);
104121
}
105-
106-
protected function setUp(): void
107-
{
108-
parent::setUp();
109-
110-
$this->context = $this->createMock(TestNotifiableModel::class);
111-
$this->message = $this->createMock(TestMessage::class);
112-
}
113122
}

0 commit comments

Comments
 (0)