Skip to content

Commit 0a378e9

Browse files
committed
Test fix
1 parent abb899f commit 0a378e9

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

tests/Unit/Domain/Messaging/Service/Builder/MessageBuilderTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PhpList\Core\Tests\Unit\Domain\Messaging\Service\Builder;
66

7-
use InvalidArgumentException;
87
use PhpList\Core\Domain\Identity\Model\Administrator;
8+
use PhpList\Core\Domain\Messaging\Exception\InvalidContextTypeException;
99
use PhpList\Core\Domain\Messaging\Model\Dto\CreateMessageDto;
1010
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageContentDto;
1111
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageFormatDto;
@@ -14,6 +14,8 @@
1414
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageScheduleDto;
1515
use PhpList\Core\Domain\Messaging\Model\Dto\MessageContext;
1616
use PhpList\Core\Domain\Messaging\Model\Message;
17+
use PhpList\Core\Domain\Messaging\Model\Message\MessageContent;
18+
use PhpList\Core\Domain\Messaging\Model\Message\MessageSchedule;
1719
use PhpList\Core\Domain\Messaging\Repository\TemplateRepository;
1820
use PhpList\Core\Domain\Messaging\Service\Builder\MessageBuilder;
1921
use PhpList\Core\Domain\Messaging\Service\Builder\MessageContentBuilder;
@@ -40,11 +42,11 @@ protected function setUp(): void
4042
$this->optionsBuilder = $this->createMock(MessageOptionsBuilder::class);
4143

4244
$this->builder = new MessageBuilder(
43-
$templateRepository,
44-
$this->formatBuilder,
45-
$this->scheduleBuilder,
46-
$this->contentBuilder,
47-
$this->optionsBuilder
45+
templateRepository: $templateRepository,
46+
messageFormatBuilder: $this->formatBuilder,
47+
messageScheduleBuilder: $this->scheduleBuilder,
48+
messageContentBuilder: $this->contentBuilder,
49+
messageOptionsBuilder: $this->optionsBuilder
4850
);
4951
}
5052

@@ -92,12 +94,12 @@ private function mockBuildCalls(CreateMessageDto $createMessageDto): void
9294
$this->scheduleBuilder->expects($this->once())
9395
->method('build')
9496
->with($createMessageDto->schedule)
95-
->willReturn($this->createMock(\PhpList\Core\Domain\Messaging\Model\Message\MessageSchedule::class));
97+
->willReturn($this->createMock(MessageSchedule::class));
9698

9799
$this->contentBuilder->expects($this->once())
98100
->method('build')
99101
->with($createMessageDto->content)
100-
->willReturn($this->createMock(\PhpList\Core\Domain\Messaging\Model\Message\MessageContent::class));
102+
->willReturn($this->createMock(MessageContent::class));
101103

102104
$this->optionsBuilder->expects($this->once())
103105
->method('build')
@@ -113,12 +115,12 @@ public function testBuildsNewMessage(): void
113115

114116
$this->mockBuildCalls($request);
115117

116-
$this->builder->build($request, $context);
118+
$this->builder->build(createMessageDto: $request, context: $context);
117119
}
118120

119121
public function testThrowsExceptionOnInvalidContext(): void
120122
{
121-
$this->expectException(InvalidArgumentException::class);
123+
$this->expectException(InvalidContextTypeException::class);
122124

123125
$this->builder->build($this->createMock(CreateMessageDto::class), new \stdClass());
124126
}
@@ -139,11 +141,11 @@ public function testUpdatesExistingMessage(): void
139141
$existingMessage
140142
->expects($this->once())
141143
->method('setSchedule')
142-
->with($this->isInstanceOf(\PhpList\Core\Domain\Messaging\Model\Message\MessageSchedule::class));
144+
->with($this->isInstanceOf(MessageSchedule::class));
143145
$existingMessage
144146
->expects($this->once())
145147
->method('setContent')
146-
->with($this->isInstanceOf(\PhpList\Core\Domain\Messaging\Model\Message\MessageContent::class));
148+
->with($this->isInstanceOf(MessageContent::class));
147149
$existingMessage
148150
->expects($this->once())
149151
->method('setOptions')

tests/Unit/Domain/Messaging/Service/Builder/MessageContentBuilderTest.php

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

55
namespace PhpList\Core\Tests\Unit\Domain\Messaging\Service\Builder;
66

7-
use InvalidArgumentException;
7+
use PhpList\Core\Domain\Messaging\Exception\InvalidDtoTypeException;
88
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageContentDto;
99
use PhpList\Core\Domain\Messaging\Service\Builder\MessageContentBuilder;
1010
use PHPUnit\Framework\TestCase;
@@ -37,7 +37,7 @@ public function testBuildsMessageContentSuccessfully(): void
3737

3838
public function testThrowsExceptionOnInvalidDto(): void
3939
{
40-
$this->expectException(InvalidArgumentException::class);
40+
$this->expectException(InvalidDtoTypeException::class);
4141

4242
$invalidDto = new \stdClass();
4343
$this->builder->build($invalidDto);

tests/Unit/Domain/Messaging/Service/Builder/MessageFormatBuilderTest.php

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

55
namespace PhpList\Core\Tests\Unit\Domain\Messaging\Service\Builder;
66

7-
use InvalidArgumentException;
7+
use PhpList\Core\Domain\Messaging\Exception\InvalidDtoTypeException;
88
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageFormatDto;
99
use PhpList\Core\Domain\Messaging\Service\Builder\MessageFormatBuilder;
1010
use PHPUnit\Framework\TestCase;
@@ -30,7 +30,7 @@ public function testBuildsMessageFormatSuccessfully(): void
3030

3131
public function testThrowsExceptionOnInvalidDto(): void
3232
{
33-
$this->expectException(InvalidArgumentException::class);
33+
$this->expectException(InvalidDtoTypeException::class);
3434

3535
$invalidDto = new \stdClass();
3636
$this->builder->build($invalidDto);

tests/Unit/Domain/Messaging/Service/Builder/MessageOptionsBuilderTest.php

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

55
namespace PhpList\Core\Tests\Unit\Domain\Messaging\Service\Builder;
66

7-
use InvalidArgumentException;
7+
use PhpList\Core\Domain\Messaging\Exception\InvalidDtoTypeException;
88
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageOptionsDto;
99
use PhpList\Core\Domain\Messaging\Service\Builder\MessageOptionsBuilder;
1010
use PHPUnit\Framework\TestCase;
@@ -37,7 +37,7 @@ public function testBuildsMessageOptionsSuccessfully(): void
3737

3838
public function testThrowsExceptionOnInvalidDto(): void
3939
{
40-
$this->expectException(InvalidArgumentException::class);
40+
$this->expectException(InvalidDtoTypeException::class);
4141

4242
$invalidDto = new \stdClass();
4343
$this->builder->build($invalidDto);

tests/Unit/Domain/Messaging/Service/Builder/MessageScheduleBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace PhpList\Core\Tests\Unit\Domain\Messaging\Service\Builder;
66

77
use DateTime;
8-
use InvalidArgumentException;
8+
use PhpList\Core\Domain\Messaging\Exception\InvalidDtoTypeException;
99
use PhpList\Core\Domain\Messaging\Model\Dto\Message\MessageScheduleDto;
1010
use PhpList\Core\Domain\Messaging\Service\Builder\MessageScheduleBuilder;
1111
use PHPUnit\Framework\TestCase;
@@ -40,7 +40,7 @@ public function testBuildsMessageScheduleSuccessfully(): void
4040

4141
public function testThrowsExceptionOnInvalidDto(): void
4242
{
43-
$this->expectException(InvalidArgumentException::class);
43+
$this->expectException(InvalidDtoTypeException::class);
4444

4545
$invalidDto = new \stdClass();
4646
$this->builder->build($invalidDto);

0 commit comments

Comments
 (0)