diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..d2454f0 --- /dev/null +++ b/.circleci/config.yml @@ -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"] diff --git a/.gitignore b/.gitignore index ee3ae7d..9dc6906 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ vendor composer.lock .php_cs.cache +.phpunit.result.cache .*.sw? .env diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cb58c1a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php -dist: trusty -sudo: required -group: edge - -php: - - 5.6 - - 7.1 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source - - composer require phpunit/phpunit 4.8.35 - -script: - - vendor/bin/phpunit diff --git a/README.md b/README.md index 727bdda..9d16a41 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/algolia.php b/algolia.php index a9ab66e..431c84d 100755 --- a/algolia.php +++ b/algolia.php @@ -1,7 +1,7 @@ setConnected(true); } - public function getBaseDb() + public function getBaseModel() { return __NAMESPACE__.'\BaseAlgolia'; } diff --git a/composer.json b/composer.json index ffac0da..b0a7a17 100644 --- a/composer.json +++ b/composer.json @@ -19,5 +19,8 @@ "pmvc-plugin/dotenv": "*" }, + "require-dev": { + "pmvc-plugin/unit": "*" + }, "minimum-stability": "dev" } diff --git a/demo.php b/demo.php index 210a949..077f479 100644 --- a/demo.php +++ b/demo.php @@ -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, diff --git a/phpunit.xml b/phpunit.xml index e58818f..e4dd003 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,23 +1,25 @@ - - + + - test.php + ./tests/test.php + ./tests/ - - - - + + + + diff --git a/tests/include.php b/tests/include.php new file mode 100644 index 0000000..5d43cc8 --- /dev/null +++ b/tests/include.php @@ -0,0 +1,7 @@ + null], [__DIR__ . '/../../']); + + diff --git a/test.php b/tests/test.php similarity index 77% rename from test.php rename to tests/test.php index 2cfbba7..797cbe9 100644 --- a/test.php +++ b/tests/test.php @@ -1,15 +1,14 @@ _plug); \PMVC\plug($this->_plug, ['app'=>'fakeApp', 'key'=>'fakeKey']); @@ -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() @@ -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