Skip to content

Commit

Permalink
prepare orm
Browse files Browse the repository at this point in the history
  • Loading branch information
HillLiu committed Nov 14, 2021
1 parent dba641f commit dadb048
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 49 deletions.
50 changes: 50 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 2.1

jobs:
unittest:
parameters:
php-version:
type: string
plugin-name:
type: string
default: "algolia"
docker:
- image: hillliu/pmvc-phpunit:<< parameters.php-version >>
working_directory: /var/www/<< parameters.plugin-name >>
steps:
- checkout
- run:
name: "Display information"
command: |
date
php -v
php -m
composer --version
phpunit --version
- run:
name: Composer install packages
command: |
composer update
composer install --prefer-source
- run:
name: PHPUnit
command: |
ENABLE_COVERAGE=false
if [ "<< parameters.php-version >>" == "8" ] && [ "$ENABLE_COVERAGE" == "true" ]; then
XDEBUG_MODE=coverage phpunit --coverage-clover clover.xml
coveralls --coverage_clover=clover.xml -v -o coveralls-upload.json
else
phpunit
fi
- store_artifacts:
path: /var/www/<< parameters.plugin-name >>/clover.xml
- store_artifacts:
path: /var/www/<< parameters.plugin-name >>/coveralls-upload.json

workflows:
run-job:
jobs:
- unittest:
matrix:
parameters:
php-version: ["8", "5.6"]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor
composer.lock
.php_cs.cache
.phpunit.result.cache
.*.sw?
.env
17 changes: 0 additions & 17 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,6 +1,6 @@
[![Latest Stable Version](https://poser.pugx.org/pmvc-plugin/algolia/v/stable)](https://packagist.org/packages/pmvc-plugin/algolia)
[![Latest Unstable Version](https://poser.pugx.org/pmvc-plugin/algolia/v/unstable)](https://packagist.org/packages/pmvc-plugin/algolia)
[![Build Status](https://travis-ci.org/pmvc-plugin/algolia.svg?branch=master)](https://travis-ci.org/pmvc-plugin/algolia)
[![CircleCI](https://circleci.com/gh/pmvc-plugin/algolia/tree/master.svg?style=svg)](https://circleci.com/gh/pmvc-plugin/algolia/tree/master)
[![License](https://poser.pugx.org/pmvc-plugin/algolia/license)](https://packagist.org/packages/pmvc-plugin/algolia)
[![Total Downloads](https://poser.pugx.org/pmvc-plugin/algolia/downloads)](https://packagist.org/packages/pmvc-plugin/algolia)

Expand Down
6 changes: 3 additions & 3 deletions algolia.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace PMVC\PlugIn\algolia;

use IdOfThings\GetDb;
use IdOfThings\GetModel;

${_INIT_CONFIG}[_CLASS] = __NAMESPACE__.'\algolia';

Expand All @@ -12,7 +12,7 @@
* @parameters string app
* @parameters string key
*/
class algolia extends GetDb
class algolia extends GetModel
{
public function init()
{
Expand All @@ -25,7 +25,7 @@ public function init()
$this->setConnected(true);
}

public function getBaseDb()
public function getBaseModel()
{
return __NAMESPACE__.'\BaseAlgolia';
}
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"pmvc-plugin/dotenv": "*"

},
"require-dev": {
"pmvc-plugin/unit": "*"
},
"minimum-stability": "dev"
}
2 changes: 1 addition & 1 deletion demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\PMVC\addPlugInFolders(['../']);

$algo = \PMVC\plug('algolia');
$park = $algo->getdb('parking');
$park = $algo->getModel('parking');

$result = $park->search('"'.\PMVC\getOption('QUERY').'"',[
'minProximity'=>1,
Expand Down
34 changes: 18 additions & 16 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="tests/include.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<file>test.php</file>
<file>./tests/test.php</file>
<directory>./tests/</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="true"/>
<ini name="display_startup_errors" value="true"/>
<env name="APP_ENV" value="testing"/>
<ini name="error_reporting" value="E_ALL" />
<ini name="display_errors" value="true" />
<ini name="display_startup_errors" value="true" />
<env name="APP_ENV" value="testing" />
</php>
</phpunit>
7 changes: 7 additions & 0 deletions tests/include.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace IdOfThings;
include __DIR__ . '/../vendor/autoload.php';

\PMVC\Load::plug(['unit' => null], [__DIR__ . '/../../']);


20 changes: 9 additions & 11 deletions test.php → tests/test.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php
namespace PMVC\PlugIn\algolia;
use PHPUnit_Framework_TestCase;

\PMVC\Load::plug();
\PMVC\addPlugInFolders(['../']);
use PMVC\TestCase;

class AlgoliaTest extends PHPUnit_Framework_TestCase

class AlgoliaTest extends TestCase
{
private $_plug = 'algolia';

function setup()
function pmvc_setup()
{
\PMVC\unplug($this->_plug);
\PMVC\plug($this->_plug, ['app'=>'fakeApp', 'key'=>'fakeKey']);
Expand All @@ -21,16 +20,15 @@ function testPlugin()
print_r(\PMVC\plug($this->_plug));
$output = ob_get_contents();
ob_end_clean();
$this->assertContains($this->_plug,$output);
$this->haveString($this->_plug,$output);
}

function testConnect()
{
$algo = \PMVC\plug($this->_plug);
$db = $algo->getDb('parking');
//$db[]=['objectID'=>'def'];
//$db[]='abc';
$db->search('d +ef');
$db = $algo->getModel('parking');
$res = $db->search('d +ef');
$this->assertTrue(!empty($res));
}

function testIsset()
Expand All @@ -43,7 +41,7 @@ function testIsset()
'code'=>200
];
$algo = \PMVC\plug($this->_plug);
$db = $algo->getDb('parking');
$db = $algo->getModel('parking');
$this->assertTrue(isset($db['fake']));
$curl['r'] = [
'code'=>404
Expand Down

0 comments on commit dadb048

Please sign in to comment.