diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-10-13 18:27:10 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-10-14 11:15:17 +0300 |
commit | 6ecf51cf7d472ef375cd637b825702498d8931c8 (patch) | |
tree | 75b80cd0fe4a2d78a921ccb29c7f90f82994687a /tests | |
parent | 868bc2917ebebb7b71d973ef6da3912ff0ae598c (diff) |
Mark immutable classes as immutable
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/AddressListTest.php | 32 | ||||
-rw-r--r-- | tests/AddressTest.php | 18 | ||||
-rw-r--r-- | tests/Unit/Listener/AddressCollectionListenerTest.php | 12 | ||||
-rw-r--r-- | tests/Unit/Listener/InteractionListenerTest.php | 10 | ||||
-rw-r--r-- | tests/Unit/Model/MessageTest.php | 4 |
5 files changed, 39 insertions, 37 deletions
diff --git a/tests/AddressListTest.php b/tests/AddressListTest.php index 80d660527..bd198a1e5 100644 --- a/tests/AddressListTest.php +++ b/tests/AddressListTest.php @@ -34,8 +34,8 @@ use OCA\Mail\AddressList; class AddressListTest extends TestCase { public function testSerialize() { $list = new AddressList([ - new Address('User 1', 'user1@domain.tld'), - new Address('User 2', 'user2@domain.tld'), + Address::fromRaw('User 1', 'user1@domain.tld'), + Address::fromRaw('User 2', 'user2@domain.tld'), ]); $expected = [ [ @@ -57,7 +57,7 @@ class AddressListTest extends TestCase { public function testParseSingleAddress() { $source = 'a@b.c'; $expected = new AddressList([ - new Address('a@b.c', 'a@b.c'), + Address::fromRaw('a@b.c', 'a@b.c'), ]); $list = AddressList::parse($source); @@ -78,8 +78,8 @@ class AddressListTest extends TestCase { public function testToHorde() { $list = new AddressList([ - new Address('A', 'a@domain.tld'), - new Address('B', 'b@domain.tld'), + Address::fromRaw('A', 'a@domain.tld'), + Address::fromRaw('B', 'b@domain.tld'), ]); $add1 = new Horde_Mail_Rfc822_Address('a@domain.tld'); $add1->personal = 'A'; @@ -117,10 +117,10 @@ class AddressListTest extends TestCase { public function testMergeIdentical() { $a = new AddressList([ - new Address('A', 'a@b.c'), + Address::fromRaw('A', 'a@b.c'), ]); $b = new AddressList([ - new Address('A', 'a@b.c'), + Address::fromRaw('A', 'a@b.c'), ]); $c = $a->merge($b); @@ -130,10 +130,10 @@ class AddressListTest extends TestCase { public function testMergeNonIdentical() { $a = new AddressList([ - new Address('A', 'a@b.c'), + Address::fromRaw('A', 'a@b.c'), ]); $b = new AddressList([ - new Address('B', 'b@b.c'), + Address::fromRaw('B', 'b@b.c'), ]); $c = $a->merge($b); @@ -145,11 +145,11 @@ class AddressListTest extends TestCase { public function testMergeMixed() { $a = new AddressList([ - new Address('A', 'a@b.c'), - new Address('B', 'b@b.c'), + Address::fromRaw('A', 'a@b.c'), + Address::fromRaw('B', 'b@b.c'), ]); $b = new AddressList([ - new Address('B', 'b@b.c'), + Address::fromRaw('B', 'b@b.c'), ]); $c = $a->merge($b); @@ -159,8 +159,8 @@ class AddressListTest extends TestCase { public function testMergeEmpty() { $a = new AddressList([ - new Address('A', 'a@b.c'), - new Address('B', 'b@b.c'), + Address::fromRaw('A', 'a@b.c'), + Address::fromRaw('B', 'b@b.c'), ]); $b = new AddressList(); @@ -173,8 +173,8 @@ class AddressListTest extends TestCase { $a = new AddressList([ ]); $b = new AddressList([ - new Address('A', 'a@b.c'), - new Address('B', 'b@b.c'), + Address::fromRaw('A', 'a@b.c'), + Address::fromRaw('B', 'b@b.c'), ]); $c = $a->merge($b); diff --git a/tests/AddressTest.php b/tests/AddressTest.php index 1c7dcb7f6..9bfb9b4a2 100644 --- a/tests/AddressTest.php +++ b/tests/AddressTest.php @@ -30,7 +30,7 @@ use OCA\Mail\Address; class AddressTest extends TestCase { public function testSerialization() { - $address = new Address('Christoph Wurst', 'christoph@domain.tld'); + $address = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld'); $expected = [ 'label' => 'Christoph Wurst', @@ -42,7 +42,7 @@ class AddressTest extends TestCase { } public function testToHorde() { - $address = new Address('Christoph Wurst', 'christoph@domain.tld'); + $address = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld'); $expected = new Horde_Mail_Rfc822_Address('christoph@domain.tld'); $expected->personal = 'Christoph Wurst'; @@ -52,7 +52,7 @@ class AddressTest extends TestCase { } public function testEqualsIdentical() { - $address = new Address('Christoph Wurst', 'christoph@domain.tld'); + $address = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld'); $equals = $address->equals($address); @@ -60,8 +60,8 @@ class AddressTest extends TestCase { } public function testEquals() { - $address1 = new Address('Christoph Wurst', 'christoph@domain1.tld'); - $address2 = new Address('Christoph Wurst', 'christoph@domain1.tld'); + $address1 = Address::fromRaw('Christoph Wurst', 'christoph@domain1.tld'); + $address2 = Address::fromRaw('Christoph Wurst', 'christoph@domain1.tld'); $equals = $address1->equals($address2); @@ -69,8 +69,8 @@ class AddressTest extends TestCase { } public function testDoesNotEqual() { - $address1 = new Address('Christoph Wurst', 'christoph@domain1.tld'); - $address2 = new Address('Christoph Wurst', 'christoph@domain2.tld'); + $address1 = Address::fromRaw('Christoph Wurst', 'christoph@domain1.tld'); + $address2 = Address::fromRaw('Christoph Wurst', 'christoph@domain2.tld'); $equals = $address1->equals($address2); @@ -78,8 +78,8 @@ class AddressTest extends TestCase { } public function testDoesNotEqualBecauseDifferentLabel() { - $address1 = new Address('Christoph Wurst', 'christoph@domain.tld'); - $address2 = new Address('Wurst Christoph', 'christoph@domain.tld'); + $address1 = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld'); + $address2 = Address::fromRaw('Wurst Christoph', 'christoph@domain.tld'); $equals = $address1->equals($address2); diff --git a/tests/Unit/Listener/AddressCollectionListenerTest.php b/tests/Unit/Listener/AddressCollectionListenerTest.php index ffb3f7597..df3814fc0 100644 --- a/tests/Unit/Listener/AddressCollectionListenerTest.php +++ b/tests/Unit/Listener/AddressCollectionListenerTest.php @@ -118,19 +118,19 @@ class AddressCollectionListenerTest extends TestCase { ); $message->expects($this->once()) ->method('getTo') - ->willReturn(new AddressList([new Address('to', 'to@email')])); + ->willReturn(new AddressList([Address::fromRaw('to', 'to@email')])); $message->expects($this->once()) ->method('getCC') - ->willReturn(new AddressList([new Address('cc', 'cc@email')])); + ->willReturn(new AddressList([Address::fromRaw('cc', 'cc@email')])); $message->expects($this->once()) ->method('getBCC') - ->willReturn(new AddressList([new Address('bcc', 'bcc@email')])); + ->willReturn(new AddressList([Address::fromRaw('bcc', 'bcc@email')])); $this->addressCollector->expects($this->once()) ->method('addAddresses') ->with($this->equalTo(new AddressList([ - new Address('to', 'to@email'), - new Address('cc', 'cc@email'), - new Address('bcc', 'bcc@email'), + Address::fromRaw('to', 'to@email'), + Address::fromRaw('cc', 'cc@email'), + Address::fromRaw('bcc', 'bcc@email'), ]))); $this->logger->expects($this->never())->method($this->anything()); diff --git a/tests/Unit/Listener/InteractionListenerTest.php b/tests/Unit/Listener/InteractionListenerTest.php index a22d81cea..b20094488 100644 --- a/tests/Unit/Listener/InteractionListenerTest.php +++ b/tests/Unit/Listener/InteractionListenerTest.php @@ -68,15 +68,15 @@ class InteractionListenerTest extends TestCase { } $to = new AddressList([ - new Address('rec 1', 'u1@domain.tld'), - new Address('rec 1', 'u2@domain.tld'), + Address::fromRaw('rec 1', 'u1@domain.tld'), + Address::fromRaw('rec 1', 'u2@domain.tld'), ]); $cc = new AddressList([ - new Address('rec 1', 'u3@domain.tld'), + Address::fromRaw('rec 1', 'u3@domain.tld'), ]); $bcc = new AddressList([ - new Address('rec 1', 'u4@domain.tld'), - new Address('rec 1', 'u2@domain.tld'), // intentional duplicate + Address::fromRaw('rec 1', 'u4@domain.tld'), + Address::fromRaw('rec 1', 'u2@domain.tld'), // intentional duplicate ]); $event = $this->createMock(MessageSentEvent::class); $message = $this->createMock(IMessage::class); diff --git a/tests/Unit/Model/MessageTest.php b/tests/Unit/Model/MessageTest.php index 1845b5c1e..104f6e8cc 100644 --- a/tests/Unit/Model/MessageTest.php +++ b/tests/Unit/Model/MessageTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /** * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @@ -49,7 +51,7 @@ class MessageTest extends TestCase { public function testFrom() { $from = new AddressList([ - new Address('Fritz', 'fritz@domain.tld'), + Address::fromRaw('Fritz', 'fritz@domain.tld'), ]); $this->message->setFrom($from); |