Skip to content

Commit

Permalink
test: adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dhsananias committed Dec 31, 2023
1 parent b740a51 commit 77fe53a
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 305 deletions.
38 changes: 19 additions & 19 deletions phpunit.xml.bak
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<phpunit colors="true"
verbose="true"
stopOnFailure="false">
<testsuites>
<testsuite name="FacelessLog Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<logging>
<log type="testdox-html" target="phpunit-report.html" />
</logging>
</phpunit>
<phpunit colors="true"
verbose="true"
stopOnFailure="false">
<testsuites>
<testsuite name="FacelessLog Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="testdox-html" target="phpunit-report.html" />
</logging>
</phpunit>
72 changes: 36 additions & 36 deletions tests/Unit/Anonymizers/BirthDateAnonymizerTest.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\BirthDateAnonymizer;

class BirthDateAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new BirthDateAnonymizer();
}

public function testAnonymizeWithDashedDateFormat()
{
$originalMessage = "User's birth date is 1990-01-01.";
$expectedMessage = "User's birth date is XXXX-XX-XX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithSlashedDateFormat()
{
$originalMessage = "User's birth date is 01/01/1990.";
$expectedMessage = "User's birth date is XX/XX/XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutDate()
{
$originalMessage = "No date in this message.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\BirthDateAnonymizer;

class BirthDateAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new BirthDateAnonymizer();
}

public function testAnonymizeWithDashedDateFormat()
{
$originalMessage = "User's birth date is 1990-01-01.";
$expectedMessage = "User's birth date is XXXX-XX-XX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithSlashedDateFormat()
{
$originalMessage = "User's birth date is 01/01/1990.";
$expectedMessage = "User's birth date is XX/XX/XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutDate()
{
$originalMessage = "No date in this message.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
70 changes: 35 additions & 35 deletions tests/Unit/Anonymizers/CreditCardAnonymizerTest.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\CreditCardAnonymizer;

class CreditCardAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new CreditCardAnonymizer();
}

public function testAnonymizeCreditCardNumber()
{
$originalMessage = "The credit card number is 1234-5678-9012-3456.";
$expectedMessage = "The credit card number is 1234-XXXX-XXXX-XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithDifferentSeparators()
{
$originalMessage = "Cards: 1234 5678 9012 3456, 1234.5678.9012.3456.";
$expectedMessage = "Cards: 1234-XXXX-XXXX-XXXX, 1234-XXXX-XXXX-XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutCreditCardNumber()
{
$originalMessage = "This message does not contain a credit card number.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\CreditCardAnonymizer;

class CreditCardAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new CreditCardAnonymizer();
}

public function testAnonymizeCreditCardNumber()
{
$originalMessage = "The credit card number is 1234-5678-9012-3456.";
$expectedMessage = "The credit card number is 1234-XXXX-XXXX-XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithDifferentSeparators()
{
$originalMessage = "Cards: 1234 5678 9012 3456, 1234.5678.9012.3456.";
$expectedMessage = "Cards: 1234-XXXX-XXXX-XXXX, 1234-XXXX-XXXX-XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutCreditCardNumber()
{
$originalMessage = "This message does not contain a credit card number.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
72 changes: 36 additions & 36 deletions tests/Unit/Anonymizers/EmailAnonymizerTest.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\EmailAnonymizer;

class EmailAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new EmailAnonymizer();
}

public function testAnonymizeEmailAddress()
{
$originalMessage = "Contact me at [email protected].";
$expectedMessage = "Contact me at j***.d**@example.com.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeMultipleEmailAddresses()
{
$originalMessage = "Emails: [email protected] and [email protected].";
$expectedMessage = "Emails: a****@example.com and b**@example.com.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutEmailAddress()
{
$originalMessage = "This message does not contain an email address.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\EmailAnonymizer;

class EmailAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new EmailAnonymizer();
}

public function testAnonymizeEmailAddress()
{
$originalMessage = "Contact me at [email protected].";
$expectedMessage = "Contact me at j***.d**@example.com.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeMultipleEmailAddresses()
{
$originalMessage = "Emails: [email protected] and [email protected].";
$expectedMessage = "Emails: a****@example.com and b**@example.com.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutEmailAddress()
{
$originalMessage = "This message does not contain an email address.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
72 changes: 36 additions & 36 deletions tests/Unit/Anonymizers/PhoneAnonymizerTest.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\PhoneAnonymizer;

class PhoneAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new PhoneAnonymizer();
}

public function testAnonymizePhoneNumber()
{
$originalMessage = "Contact number is +123 4567 8901.";
$expectedMessage = "Contact number is +123 4567 XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeMultiplePhoneNumbers()
{
$originalMessage = "Numbers are (123) 456-7890 and 123.456.7890.";
$expectedMessage = "Numbers are (123) 456-XXXX and 123.456.XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutPhoneNumber()
{
$originalMessage = "This message does not contain a phone number.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
<?php

namespace Unit\Anonymizers;

use PHPUnit\Framework\TestCase;
use FacelessLog\Anonymizers\PhoneAnonymizer;

class PhoneAnonymizerTest extends TestCase
{
private $anonymizer;

protected function setUp(): void
{
$this->anonymizer = new PhoneAnonymizer();
}

public function testAnonymizePhoneNumber()
{
$originalMessage = "Contact number is +123 4567 8901.";
$expectedMessage = "Contact number is +123 4567 XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeMultiplePhoneNumbers()
{
$originalMessage = "Numbers are (123) 456-7890 and 123.456.7890.";
$expectedMessage = "Numbers are (123) 456-XXXX and 123.456.XXXX.";
$this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage));
}

public function testAnonymizeWithoutPhoneNumber()
{
$originalMessage = "This message does not contain a phone number.";
$this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage));
}
}
Loading

0 comments on commit 77fe53a

Please sign in to comment.