Skip to content

Commit 18f574c

Browse files
committed
Merge branch 'master' into dev
2 parents 607e3b6 + 675d087 commit 18f574c

File tree

7 files changed

+43
-26
lines changed

7 files changed

+43
-26
lines changed

.travis.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,40 @@ sudo: false
1313
env:
1414
global:
1515
- DEFAULT=1
16+
- CODECOVERAGE=0
1617

1718
matrix:
1819
fast_finish: true
1920

2021
include:
22+
- php: 7.2
23+
env: CODECOVERAGE=1 DEFAULT=0
24+
2125
- php: 7.0
2226
env: PHPCS=1 DEFAULT=0
2327

2428
- php: 7.0
2529
env: PHPSTAN=1 DEFAULT=0
2630

31+
- php: 5.6
32+
env: PREFER_LOWEST=1
33+
2734
before_script:
2835
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
2936

30-
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan; fi
37+
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.9; fi
3138
- if [[ $PHPSTAN != 1 ]]; then composer install --no-interaction; fi
3239

3340
script:
34-
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then ./vendor/bin/phpunit --coverage-clover=clover.xml; fi
35-
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then ./vendor/bin/phpunit; fi
41+
- if [[ $CODECOVERAGE = 1 ]]; then ./vendor/bin/phpunit --coverage-clover=clover.xml; fi
42+
- if [[ $DEFAULT = 1 ]]; then ./vendor/bin/phpunit; fi
3643

3744
- if [[ $PHPCS = 1 ]]; then ./vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
3845

3946
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -l 2 src; fi
4047

4148
after_success:
42-
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
49+
- if [[ $CODECOVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi
4350

4451
notifications:
4552
email: false

src/AbstractDriver.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,24 @@ public function getWebservice($name)
154154
* Returns a logger instance
155155
*
156156
* @return \Psr\Log\LoggerInterface
157+
*
158+
* @deprecated 1.4.0 Use getLogger() instead.
157159
*/
158160
public function logger()
159161
{
160162
return $this->logger;
161163
}
162164

165+
/**
166+
* Returns a logger instance
167+
*
168+
* @return \Psr\Log\LoggerInterface
169+
*/
170+
public function getLogger()
171+
{
172+
return $this->logger;
173+
}
174+
163175
/**
164176
* Returns the connection name used in the configuration
165177
*
@@ -175,7 +187,8 @@ public function configName()
175187
*
176188
* @param bool|null $enable whether to turn logging on or disable it. Use null to read current value.
177189
* @return bool
178-
* @deprecated 2.0.0 Use enableQueryLogging(), disableQueryLogging() and getQueryLogging() instead.
190+
*
191+
* @deprecated 1.4.0 Use enableQueryLogging()/disableQueryLogging()/isQueryLoggingEnabled() instead.
179192
*/
180193
public function logQueries($enable = null)
181194
{
@@ -211,11 +224,11 @@ public function disableQueryLogging()
211224
}
212225

213226
/**
214-
* Get the current state of query logging for the driver
227+
* Check if query logging is enabled.
215228
*
216229
* @return bool
217230
*/
218-
public function getQueryLogging()
231+
public function isQueryLoggingEnabled()
219232
{
220233
return $this->_logQueries;
221234
}
@@ -258,7 +271,7 @@ public function __debugInfo()
258271
return [
259272
'client' => $this->getClient(),
260273
'logger' => $this->logger(),
261-
'query_logging' => $this->getQueryLogging(),
274+
'query_logging' => $this->isQueryLoggingEnabled(),
262275
'webservices' => array_keys($this->_webservices)
263276
];
264277
}

src/Model/EndpointRegistry.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Cake\Core\App;
66
use Cake\Datasource\ConnectionManager;
77
use Cake\Utility\Inflector;
8-
use Muffin\Webservice\AbstractDriver;
98
use RuntimeException;
109

1110
/**

src/Webservice/Webservice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ public function describe($endpoint)
213213
$shortName = App::shortName(get_class($this), 'Webservice', 'Webservice');
214214
list($plugin, $name) = pluginSplit($shortName);
215215

216-
$schemaShortName = implode('.', array_filter([$plugin, Inflector::classify($endpoint)]));
216+
$endpoint = Inflector::classify(str_replace('-', '_', $endpoint));
217+
$schemaShortName = implode('.', array_filter([$plugin, $endpoint]));
217218
$schemaClassName = App::className($schemaShortName, 'Model/Endpoint/Schema', 'Schema');
218219
if ($schemaClassName) {
219220
return new $schemaClassName($endpoint);
@@ -340,7 +341,7 @@ protected function _createResource($resourceClass, array $properties = [])
340341
*/
341342
protected function _logQuery(Query $query, LoggerInterface $logger)
342343
{
343-
if (!$this->getDriver()->getQueryLogging()) {
344+
if (!$this->getDriver()->isQueryLoggingEnabled()) {
344345
return;
345346
}
346347

tests/TestCase/AbstractDriverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ public function testEnableQueryLogging()
4949
$driver = new Test();
5050
$driver->enableQueryLogging();
5151

52-
$this->assertTrue($driver->getQueryLogging());
52+
$this->assertTrue($driver->isQueryLoggingEnabled());
5353
}
5454

5555
public function testDisableQueryLogging()
5656
{
5757
$driver = new Test();
5858
$driver->disableQueryLogging();
5959

60-
$this->assertFalse($driver->getQueryLogging());
60+
$this->assertFalse($driver->isQueryLoggingEnabled());
6161
}
6262

6363
public function testDebugInfo()

tests/TestCase/Webservice/WebserviceTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ public function testExecuteWithoutDriver()
8484
$webservice->execute($query);
8585
}
8686

87-
public function testExecuteLoggingWithoutLogger()
88-
{
89-
$query = new Query($this->webservice, new Endpoint());
90-
91-
$this->webservice->execute($query);
92-
}
93-
9487
public function testExecuteLoggingWithLogger()
9588
{
9689
$logger = $this->getMockBuilder('Cake\Log\Engine\ConsoleLog')
@@ -210,6 +203,15 @@ public function testTransformResults()
210203
$this->assertInstanceOf('\Muffin\Webservice\Model\Resource', $resources[0]);
211204
}
212205

206+
public function testDescribe()
207+
{
208+
$service = new TestWebservice();
209+
210+
$result = $service->describe('test');
211+
$this->assertInstanceOf('\Muffin\Webservice\Model\Schema', $result);
212+
$this->assertEquals('Test', $result->name());
213+
}
214+
213215
public function testDebugInfo()
214216
{
215217
$this->assertEquals([

tests/bootstrap.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,8 @@
8585
]
8686
]);
8787

88-
// Ensure default test connection is defined
89-
if (!getenv('db_dsn')) {
90-
putenv('db_dsn=sqlite:/' . TMP . 'debug_kit_test.sqlite');
91-
}
92-
9388
$config = [
94-
'url' => getenv('db_dsn'),
89+
'url' => 'sqlite:/' . TMP . 'webservice_test.sqlite',
9590
'timezone' => 'UTC',
9691
];
9792

0 commit comments

Comments
 (0)