diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 4c6d8be8..de08d0b5 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -40,6 +40,7 @@ jobs: - name: Run tests timeout-minutes: 5 run: | - pnpm prettier composer run phpcs:ci composer run phpstan:ci + composer run phpunit + pnpm prettier diff --git a/.gitignore b/.gitignore index f022ec4b..043f162c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,14 @@ vendor/ node_modules/ +# testing and code styling output +/build/ +.php-cs-fixer.cache +.phpunit.result.cache + # misc .DS_Store .env .idea/ -.php-cs-fixer.cache *.swp diff --git a/Jenkinsfile b/Jenkinsfile index 136d7683..c8af7cb9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,6 +30,12 @@ pipeline { } } + stage('Run Test Suite') { + steps { + sh 'composer run phpunit' + } + } + stage('Check Formating') { steps { sh 'n -d exec engine pnpm prettier' diff --git a/Swat/SwatByteCellRenderer.php b/Swat/SwatByteCellRenderer.php index 33103f73..5fd87fd6 100644 --- a/Swat/SwatByteCellRenderer.php +++ b/Swat/SwatByteCellRenderer.php @@ -14,7 +14,7 @@ class SwatByteCellRenderer extends SwatCellRenderer /** * Value in bytes. * - * @var float + * @var int */ public $value; diff --git a/Swat/SwatCascadeFlydown.php b/Swat/SwatCascadeFlydown.php index 8870c56b..5e127b57 100644 --- a/Swat/SwatCascadeFlydown.php +++ b/Swat/SwatCascadeFlydown.php @@ -166,7 +166,7 @@ protected function &getOptions() // if the options array doesn't exist for this parent_value, then // assume that means we don't want any values in this flydown for // that option. - $options = [new SwatOption(null, null)]; + $options = [new SwatOption(null, '')]; } return $options; diff --git a/Swat/SwatCellRendererSet.php b/Swat/SwatCellRendererSet.php index 68cadd4c..246ecd0c 100644 --- a/Swat/SwatCellRendererSet.php +++ b/Swat/SwatCellRendererSet.php @@ -212,7 +212,7 @@ public function getRendererByPosition($position = 0) throw new SwatObjectNotFoundException( 'Set does not contain that many renderers.', 0, - $position, + (string) $position, ); } diff --git a/Swat/SwatCheckboxCellRenderer.php b/Swat/SwatCheckboxCellRenderer.php index a9100642..cc373db6 100644 --- a/Swat/SwatCheckboxCellRenderer.php +++ b/Swat/SwatCheckboxCellRenderer.php @@ -153,7 +153,7 @@ public function render() echo ''; echo ''; - if ($this->title !== null) { + if (isset($label_tag)) { $label_tag->displayContent(); $label_tag->close(); } diff --git a/Swat/SwatCheckboxTree.php b/Swat/SwatCheckboxTree.php index 765a2db4..7bb67fbe 100644 --- a/Swat/SwatCheckboxTree.php +++ b/Swat/SwatCheckboxTree.php @@ -170,7 +170,7 @@ protected function validate(SwatDataTreeNode $node, $is_parent_selected) : $is_parent_selected && !$is_selected; return array_reduce( - $node->getChildren(), + iterator_to_array($node->getChildren()), function ($carry, $child) use ($is_selected) { return $carry && $this->validate($child, $is_selected); }, @@ -269,7 +269,7 @@ private function displayNode( // display children $child_nodes = $node->getChildren(); - if (count($child_nodes) > 0) { + if (iterator_count($child_nodes) > 0) { echo '