Skip to content

Commit

Permalink
fixed get DB version code; added coding style workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
k00ni committed Aug 29, 2023
1 parent 12c8eaf commit 20a85c8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/coding-styles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Coding Styles"

on: [push, pull_request]

jobs:
tests:
name: Coding Styles
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php:
- 8.2

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-values: memory_limit=1G
tools: cs2pr

- name: Validate Composer files
run: composer validate --no-check-all --strict

- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader

- name: Coding styles
run: php vendor/bin/php-cs-fixer fix --verbose --dry-run --format=checkstyle | cs2pr
2 changes: 1 addition & 1 deletion src/ARC2/Store/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class AbstractAdapter
protected $queries = [];

/**
* @param array $configuration Default is array().
* @param array $configuration default is array()
*/
public function __construct(array $configuration = [])
{
Expand Down
4 changes: 1 addition & 3 deletions src/ARC2/Store/Adapter/PDOAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace ARC2\Store\Adapter;

use Exception;

/**
* PDO Adapter - Handles database operations using PDO.
*/
Expand Down Expand Up @@ -242,7 +240,7 @@ public function getServerVersion(): string
return $this->db->query('select version()')->fetchColumn();
}

throw new Exception('You need to connect to DB server first. Use connect() before this function.');
throw new \Exception('You need to connect to DB server first. Use connect() before this function.');
}

public function getErrorCode()
Expand Down
8 changes: 4 additions & 4 deletions tests/db_adapter_depended/store/ARC2_StoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ public function testEnableFulltextSearch()
// just check pattern
public function testGetDBVersion()
{
$pattern = '/[0-9]{1,}\.[0-9]{1,}\.[0-9]{2}/';

$result = preg_match($pattern, $this->fixture->getDBVersion(), $match);
$this->assertEquals(1, $result, $this->fixture->getDBVersion());
$this->assertEquals(
$this->fixture->getDBObject()->getConnection()->query('select version()')->fetchColumn(),
$this->fixture->getDBVersion()
);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ public function testQuery()

public function testGetServerVersion()
{
$pattern = '/[0-9]{1,}\.[0-9]{1,}\.[0-9]{2}/';

// check that server version looks like 5.5.21
$this->assertEquals(1, preg_match($pattern, $this->fixture->getServerVersion()));
$this->assertEquals(
$this->fixture->getConnection()->query('select version()')->fetchColumn(),
$this->fixture->getServerVersion()
);
}

/*
Expand Down

0 comments on commit 20a85c8

Please sign in to comment.