diff --git a/src/Mail/Envelop.php b/src/Mail/Envelop.php index 1a4de18d..c86f28e5 100644 --- a/src/Mail/Envelop.php +++ b/src/Mail/Envelop.php @@ -4,9 +4,10 @@ namespace Bow\Mail; -use Bow\Mail\Exception\MailException; +use Bow\View\View; use Bow\Support\Str; use InvalidArgumentException; +use Bow\Mail\Exception\MailException; class Envelop { @@ -486,7 +487,7 @@ public function fromIsDefined(): bool */ public function view(string $view, array $data = []): Envelop { - $this->message(view($view, $data)->getContent()); + $this->message(View::parse($view, $data)->getContent()); return $this; } diff --git a/tests/Messaging/MessagingTest.php b/tests/Messaging/MessagingTest.php index 7faf4709..ac5c53ef 100644 --- a/tests/Messaging/MessagingTest.php +++ b/tests/Messaging/MessagingTest.php @@ -2,14 +2,15 @@ namespace Bow\Tests\Messaging; -use Bow\Database\Barry\Model; +use Bow\View\View; use Bow\Mail\Envelop; -use Bow\Messaging\MessagingQueueProducer; -use Bow\Queue\Connection as QueueConnection; +use Bow\Database\Barry\Model; +use PHPUnit\Framework\TestCase; +use Bow\Tests\Config\TestingConfiguration; use Bow\Tests\Messaging\Stubs\TestMessage; -use Bow\Tests\Messaging\Stubs\TestNotifiableModel; +use Bow\Queue\Connection as QueueConnection; use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; +use Bow\Tests\Messaging\Stubs\TestNotifiableModel; class MessagingTest extends TestCase { @@ -22,14 +23,9 @@ public static function setUpBeforeClass(): void parent::setUpBeforeClass(); // Initialize queue connection - static::$queueConnection = new QueueConnection([ - 'default' => 'sync', - 'connections' => [ - 'sync' => [ - 'driver' => 'sync' - ] - ] - ]); + $config = TestingConfiguration::getConfig(); + + View::configure($config["view"]); } public function test_can_send_message_synchronously(): void diff --git a/tests/Queue/EventQueueTest.php b/tests/Queue/EventQueueTest.php index 31c52429..26ca7bee 100644 --- a/tests/Queue/EventQueueTest.php +++ b/tests/Queue/EventQueueTest.php @@ -1,18 +1,21 @@ 'sync', - 'connections' => [ - 'sync' => [ - 'driver' => 'sync' - ] - ] + TestingConfiguration::withConfigurations([ + CacheConfiguration::class, + QueueConfiguration::class, + EnvConfiguration::class, + LoggerConfiguration::class, + MailConfiguration::class, + ViewConfiguration::class, ]); + + $config = TestingConfiguration::getConfig(); + $config->boot(); + + static::$connection = new QueueConnection($config["queue"]); + } + + protected function setUp(): void + { + parent::setUp(); + + $this->context = $this->createMock(TestNotifiableModel::class); + $this->message = $this->createMock(TestMessage::class); } public function test_can_send_message_synchronously(): void @@ -48,7 +65,7 @@ public function test_can_send_message_to_queue(): void $this->assertInstanceOf(MessagingQueueProducer::class, $producer); // Push to queue and verify - static::$queueConnection->getAdapter()->push($producer); + static::$connection->setConnection("beanstalkd")->getAdapter()->push($producer); $this->context->setMessageQueue($this->message); } @@ -62,7 +79,7 @@ public function test_can_send_message_to_specific_queue(): void $this->assertInstanceOf(MessagingQueueProducer::class, $producer); // Push to specific queue and verify - $adapter = static::$queueConnection->getAdapter(); + $adapter = static::$connection->setConnection("beanstalkd")->getAdapter(); $adapter->setQueue($queue); $adapter->push($producer); @@ -78,7 +95,7 @@ public function test_can_send_message_with_delay(): void $this->assertInstanceOf(MessagingQueueProducer::class, $producer); // Push to queue and verify - $adapter = static::$queueConnection->getAdapter(); + $adapter = static::$connection->setConnection("beanstalkd")->getAdapter(); $adapter->setSleep($delay); $adapter->push($producer); @@ -95,19 +112,11 @@ public function test_can_send_message_with_delay_on_specific_queue(): void $this->assertInstanceOf(MessagingQueueProducer::class, $producer); // Push to specific queue with delay and verify - $adapter = static::$queueConnection->getAdapter(); + $adapter = static::$connection->setConnection("beanstalkd")->getAdapter(); $adapter->setQueue($queue); $adapter->setSleep($delay); $adapter->push($producer); $this->context->sendMessageLaterOn($delay, $queue, $this->message); } - - protected function setUp(): void - { - parent::setUp(); - - $this->context = $this->createMock(TestNotifiableModel::class); - $this->message = $this->createMock(TestMessage::class); - } } diff --git a/tests/Queue/QueueTest.php b/tests/Queue/QueueTest.php index d1f28868..8a9ec4e9 100644 --- a/tests/Queue/QueueTest.php +++ b/tests/Queue/QueueTest.php @@ -2,23 +2,24 @@ namespace Bow\Tests\Queue; -use Bow\Cache\Adapters\RedisAdapter; +use Bow\Database\Database; +use PHPUnit\Framework\TestCase; use Bow\Cache\CacheConfiguration; +use Bow\Queue\Adapters\SQSAdapter; +use Bow\Queue\Adapters\SyncAdapter; +use Bow\Cache\Adapters\RedisAdapter; use Bow\Configuration\EnvConfiguration; -use Bow\Configuration\LoggerConfiguration; -use Bow\Database\Database; use Bow\Database\DatabaseConfiguration; -use Bow\Queue\Adapters\BeanstalkdAdapter; use Bow\Queue\Adapters\DatabaseAdapter; -use Bow\Queue\Adapters\SQSAdapter; -use Bow\Queue\Adapters\SyncAdapter; -use Bow\Queue\Connection as QueueConnection; +use Bow\Tests\Queue\Stubs\PetModelStub; +use Bow\Queue\Adapters\BeanstalkdAdapter; +use Bow\Configuration\LoggerConfiguration; use Bow\Tests\Config\TestingConfiguration; -use Bow\Tests\Queue\Stubs\BasicProducerStubs; +use Bow\Queue\Connection as QueueConnection; use Bow\Tests\Queue\Stubs\ModelProducerStub; -use Bow\Tests\Queue\Stubs\PetModelStub; +use Bow\Tests\Queue\Stubs\BasicProducerStubs; -class QueueTest extends \PHPUnit\Framework\TestCase +class QueueTest extends TestCase { private static $connection;