Skip to content

Commit 9d0d701

Browse files
committed
Adding code quality checks
1 parent 9df5d97 commit 9d0d701

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

.github/workflows/code.quality.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Code Quality 🏆"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up PHP
12+
uses: shivammathur/setup-php@v2
13+
with:
14+
php-version: "8.0"
15+
- name: Install dependencies
16+
run: composer install
17+
- name: Run tests
18+
run: composer test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
vendor
3+
composer.lock
34
.phpunit.result.cache

phpunit.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php">
3+
<testsuites>
4+
<testsuite name="Application Test Suite">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

tests/ConditionalHelpersTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use GaryDavisonOs\ConditionalHelpers\ConditionalHelpers;
4+
use PHPUnit\Framework\TestCase;
5+
6+
class ConditionalHelpersTest extends TestCase
7+
{
8+
public function testIsArrayHasLength()
9+
{
10+
$array = [1, 2, 3];
11+
$this->assertTrue(ConditionalHelpers::isArrayHasLength($array));
12+
13+
$emptyArray = [];
14+
$this->assertFalse(ConditionalHelpers::isArrayHasLength($emptyArray));
15+
}
16+
17+
public function testIsStringHasLength()
18+
{
19+
$string = "Hello, World!";
20+
$this->assertTrue(ConditionalHelpers::isStringHasLength($string));
21+
22+
$emptyString = "";
23+
$this->assertFalse(ConditionalHelpers::isStringHasLength($emptyString));
24+
}
25+
26+
public function testIsBooleanTrue()
27+
{
28+
$this->assertTrue(ConditionalHelpers::isBooleanTrue(true));
29+
$this->assertFalse(ConditionalHelpers::isBooleanTrue(false));
30+
}
31+
32+
public function testIsBooleanFalse()
33+
{
34+
$this->assertTrue(ConditionalHelpers::isBooleanFalse(false));
35+
$this->assertFalse(ConditionalHelpers::isBooleanFalse(true));
36+
}
37+
}

0 commit comments

Comments
 (0)