Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create php.yml #27

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHP Composer

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run test suite
run: php vendor/bin/phpunit -c phpunit.xml.dist
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Doctrine Functions
==================

[![Build Status](https://travis-ci.org/luxifer/doctrine-functions.svg?branch=master)](https://travis-ci.org/luxifer/doctrine-functions) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/badges/quality-score.png?s=32406f6c6df4378a2f352bd062707d3c7a0216ea)](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/) [![Code Coverage](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/badges/coverage.png?s=6701d974c062e2c98ec2a556ba8ba4db76667e68)](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/) [![Latest Stable Version](https://poser.pugx.org/luxifer/doctrine-functions/v/stable.png)](https://packagist.org/packages/luxifer/doctrine-functions) [![Total Downloads](https://poser.pugx.org/luxifer/doctrine-functions/downloads.png)](https://packagist.org/packages/luxifer/doctrine-functions)
[[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/badges/quality-score.png?s=32406f6c6df4378a2f352bd062707d3c7a0216ea)](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/) [![Code Coverage](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/badges/coverage.png?s=6701d974c062e2c98ec2a556ba8ba4db76667e68)](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/) [![Latest Stable Version](https://poser.pugx.org/luxifer/doctrine-functions/v/stable.png)](https://packagist.org/packages/luxifer/doctrine-functions) [![Total Downloads](https://poser.pugx.org/luxifer/doctrine-functions/downloads.png)](https://packagist.org/packages/luxifer/doctrine-functions)

This package contains doctrine functions, you can contribute by forking it and propose pull request with your own functions.
List of available functions:
Expand Down
21 changes: 13 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"type": "library",
"description": "Doctrine DQL Functions for Mysql",
"homepage": "http://luxifer.github.io/doctrine-functions/",
"keywords": ["database", "mysql", "dql"],
"keywords": [
"database",
"mysql",
"dql"
],
"license": "MIT",
"authors": [
{
Expand All @@ -15,20 +19,21 @@
],
"require": {
"php": ">=8.2",
"doctrine/orm": ">=3.0"
"doctrine/orm": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^11.0",
"symfony/cache": "^7.2"
},
"autoload": {
"psr-4": {
"Luxifer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Luxifer\\Tests\\": "tests/"
}
},
"autoload-dev": {
"psr-4": {
"Luxifer\\Tests\\": "tests/"
}
},
"minimum-stability": "stable"
}
15 changes: 5 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>
<testsuites>
<testsuite name="Doctrine Functions Test Suite">
Expand All @@ -30,6 +25,6 @@
</groups>

<logging>
<log type="coverage-clover" target="coverage.clover"/>
<log type="coverage-clover" target="coverage.clover" />
</logging>
</phpunit>
8 changes: 4 additions & 4 deletions tests/DQLFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Luxifer\Tests;

use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\ORMSetup;
use Luxifer\Tests\Mocks\EntityManagerMock;
use Luxifer\Tests\Mocks\QuotingStrategy;
use PHPUnit\Framework\TestCase;
Expand All @@ -17,12 +17,12 @@ abstract class DQLFunctionTest extends TestCase
/** @var EntityManagerMock */
protected $em;

public function setUp()
public function setUp(): void
{
$this->em = $this->getEntityManagerInstanceMock();
}

public function tearDown()
public function tearDown(): void
{
unset($this->em);
}
Expand All @@ -35,7 +35,7 @@ public function tearDown()
*/
protected function getEntityManagerInstanceMock()
{
$this->config = Setup::createAnnotationMetadataConfiguration(array('./Fixtures'), true);
$this->config = ORMSetup::createAttributeMetadataConfiguration(array('./Fixtures'), true);
$this->config->setQuoteStrategy(new QuotingStrategy());

$conn = array(
Expand Down
2 changes: 1 addition & 1 deletion tests/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testDateParts($part)
* Data provider
* @codeCoverageIgnore
*/
public function partsProvider()
public static function partsProvider()
{
return array(
array('date'),
Expand Down
23 changes: 20 additions & 3 deletions tests/Mocks/DriverMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

namespace Luxifer\Tests\Mocks;

use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\ServerVersionProvider;
use SensitiveParameter;

class DriverMock implements \Doctrine\DBAL\Driver
class DriverMock implements Driver
{
private $_platformMock;

private $_schemaManagerMock;

public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
public function connect(
#[SensitiveParameter]
array $params,
): DriverConnection
{
return new DriverConnectionMock();
}
Expand All @@ -28,7 +37,7 @@ protected function _constructPdoDsn(array $params)
/**
* @override
*/
public function getDatabasePlatform()
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform
{
if ( ! $this->_platformMock) {
$this->_platformMock = new DatabasePlatformMock;
Expand All @@ -48,6 +57,14 @@ public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
}
}

/**
* @override
*/
public function getExceptionConverter(): ExceptionConverter
{
return new ExceptionConverterMock();
}

/* MOCK API */

public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
Expand Down
18 changes: 18 additions & 0 deletions tests/Mocks/ExceptionConverterMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Luxifer\Tests\Mocks;

use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Query;

class ExceptionConverterMock implements ExceptionConverter
{
public function convert(Exception $exception, Query|null $query): DriverException
{
return new DriverException($exception, $query);
}
}
2 changes: 1 addition & 1 deletion tests/Mocks/QuotingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class QuotingStrategy extends DefaultQuoteStrategy
{
public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null)
public function getColumnAlias(string $columnName, int $counter, AbstractPlatform $platform, ClassMetadata|null $class = null): string
{
// 1 ) Concatenate column name and counter
// 2 ) Trim the column alias to the maximum identifier length of the platform.
Expand Down
4 changes: 2 additions & 2 deletions tests/StringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testConcatWs($dql, $sql)
* Data provider
* @codeCoverageIgnore
*/
public function concatProvider()
public static function concatProvider()
{
return array(
array("'', '1', '2'", "'', '1', '2'"),
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testIfElse($dql, $sql)
/**
* @codeCoverageIgnore
*/
public function ifProvider()
public static function ifProvider()
{
return array(
array('1 > 2, e.id, e.somedate', '1 > 2, s0_.id, s0_.somedate'),
Expand Down
Loading