From 73c2fd5be7ac53ca7d64247596801ca593f1c784 Mon Sep 17 00:00:00 2001 From: Fejan <63099555+fejan-malek@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:43:28 +0530 Subject: [PATCH] Sync rotational-cipher (#799) [no important files changed] --- .../RotationalCipherTest.php | 67 ++++++++++++++----- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/exercises/practice/rotational-cipher/RotationalCipherTest.php b/exercises/practice/rotational-cipher/RotationalCipherTest.php index dfdcc3c2..4c9744d6 100644 --- a/exercises/practice/rotational-cipher/RotationalCipherTest.php +++ b/exercises/practice/rotational-cipher/RotationalCipherTest.php @@ -4,115 +4,148 @@ class RotationalCipherTest extends PHPUnit\Framework\TestCase { - private RotationalCipher $rotationalCipher; - public static function setUpBeforeClass(): void { require_once 'RotationalCipher.php'; } - protected function setUp(): void - { - $this->rotationalCipher = new RotationalCipher(); - } - /** * uuid: 74e58a38-e484-43f1-9466-877a7515e10f + * @testdox Rotate a by 0, same output as input */ public function testRotateAByZero(): void { $expected = 'a'; - $actual = $this->rotationalCipher->rotate('a', 0); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('a', 0); + $this->assertEquals($expected, $actual); } /** * uuid: 7ee352c6-e6b0-4930-b903-d09943ecb8f5 + * @testdox Rotate a by 1 */ public function testRotateAByOne(): void { $expected = 'b'; - $actual = $this->rotationalCipher->rotate('a', 1); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('a', 1); + $this->assertEquals($expected, $actual); } /** * uuid: edf0a733-4231-4594-a5ee-46a4009ad764 + * @testdox Rotate a by 26, same output as input */ public function testRotateABy26(): void { $expected = 'a'; - $actual = $this->rotationalCipher->rotate('a', 26); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('a', 26); + $this->assertEquals($expected, $actual); } /** * uuid: e3e82cb9-2a5b-403f-9931-e43213879300 + * @testdox Rotate m by 13 */ public function testRotateMBy13(): void { $expected = 'z'; - $actual = $this->rotationalCipher->rotate('m', 13); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('m', 13); + $this->assertEquals($expected, $actual); } /** * uuid: 19f9eb78-e2ad-4da4-8fe3-9291d47c1709 + * @testdox Rotate n by 13 with wrap around alphabet */ public function testRotateNBy13WithWrapAroundAlphabet(): void { $expected = 'a'; - $actual = $this->rotationalCipher->rotate('n', 13); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('n', 13); + $this->assertEquals($expected, $actual); } /** * uuid: a116aef4-225b-4da9-884f-e8023ca6408a + * @testdox Rotate capital letters */ public function testRotateCapitalLetters(): void { $expected = 'TRL'; - $actual = $this->rotationalCipher->rotate('OMG', 5); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('OMG', 5); + $this->assertEquals($expected, $actual); } /** * uuid: 71b541bb-819c-4dc6-a9c3-132ef9bb737b + * @testdox Rotate spaces */ public function testRotateSpaces(): void { $expected = 'T R L'; - $actual = $this->rotationalCipher->rotate('O M G', 5); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('O M G', 5); + $this->assertEquals($expected, $actual); } /** * uuid: ef32601d-e9ef-4b29-b2b5-8971392282e6 + * @testdox Rotate numbers */ public function testRotateNumbers(): void { $expected = 'Xiwxmrk 1 2 3 xiwxmrk'; - $actual = $this->rotationalCipher->rotate('Testing 1 2 3 testing', 4); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('Testing 1 2 3 testing', 4); + $this->assertEquals($expected, $actual); } /** * uuid: 32dd74f6-db2b-41a6-b02c-82eb4f93e549 + * @testdox Rotate punctuation */ public function testRotatePunctuation(): void { $expected = "Gzo'n zvo, Bmviyhv!"; - $actual = $this->rotationalCipher->rotate("Let's eat, Grandma!", 21); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate("Let's eat, Grandma!", 21); + $this->assertEquals($expected, $actual); } /** * uuid: 9fb93fe6-42b0-46e6-9ec1-0bf0a062d8c9 + * @testdox Rotate all letters */ public function testRotateAllLetters(): void { $expected = 'Gur dhvpx oebja sbk whzcf bire gur ynml qbt.'; - $actual = $this->rotationalCipher->rotate('The quick brown fox jumps over the lazy dog.', 13); + $rotationalCipher = new RotationalCipher(); + + $actual = $rotationalCipher->rotate('The quick brown fox jumps over the lazy dog.', 13); + $this->assertEquals($expected, $actual); } }