Skip to content

Commit 5c6e4f9

Browse files
authored
Merge pull request #81 from UseMuffin/cake-3.7
Add new methods to fix errors with DebugKit on Cake 3.7.
2 parents 7fbc7ba + e8f193e commit 5c6e4f9

File tree

5 files changed

+60
-11
lines changed

5 files changed

+60
-11
lines changed

.travis.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: php
22

33
php:
44
- 7.0
5-
- 7.2
65
- 7.1
76
- 5.6
87

@@ -13,33 +12,40 @@ sudo: false
1312
env:
1413
global:
1514
- DEFAULT=1
15+
- CODECOVERAGE=0
1616

1717
matrix:
1818
fast_finish: true
1919

2020
include:
21+
- php: 7.2
22+
env: CODECOVERAGE=1 DEFAULT=0
23+
2124
- php: 7.0
2225
env: PHPCS=1 DEFAULT=0
2326

2427
- php: 7.0
2528
env: PHPSTAN=1 DEFAULT=0
2629

30+
- php: 5.6
31+
env: PREFER_LOWEST=1
32+
2733
before_script:
2834
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
2935

3036
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.9; fi
3137
- if [[ $PHPSTAN != 1 ]]; then composer install --no-interaction; fi
3238

3339
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
40+
- if [[ $CODECOVERAGE = 1 ]]; then ./vendor/bin/phpunit --coverage-clover=clover.xml; fi
41+
- if [[ $DEFAULT = 1 ]]; then ./vendor/bin/phpunit; fi
3642

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

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

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

4450
notifications:
4551
email: false

src/AbstractDriver.php

+49-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Cake\Utility\Inflector;
77
use Muffin\Webservice\Exception\MissingWebserviceClassException;
88
use Muffin\Webservice\Exception\UnimplementedWebserviceMethodException;
9-
use Muffin\Webservice\Webservice\Webservice;
109
use Muffin\Webservice\Webservice\WebserviceInterface;
1110
use Psr\Log\LoggerAwareInterface;
1211
use Psr\Log\LoggerAwareTrait;
@@ -111,12 +110,24 @@ public function webservice($name, WebserviceInterface $webservice = null)
111110
* Returns a logger instance
112111
*
113112
* @return \Psr\Log\LoggerInterface
113+
*
114+
* @deprecated 1.4.0 Use getLogger() instead.
114115
*/
115116
public function logger()
116117
{
117118
return $this->logger;
118119
}
119120

121+
/**
122+
* Returns a logger instance
123+
*
124+
* @return \Psr\Log\LoggerInterface
125+
*/
126+
public function getLogger()
127+
{
128+
return $this->logger;
129+
}
130+
120131
/**
121132
* Returns the connection name used in the configuration
122133
*
@@ -134,6 +145,8 @@ public function configName()
134145
* Use null to read current value.
135146
*
136147
* @return bool
148+
*
149+
* @deprecated 1.4.0 Use enableQueryLogging()/disableQueryLogging()/isQueryLoggingEnabled() instead.
137150
*/
138151
public function logQueries($enable = null)
139152
{
@@ -144,6 +157,40 @@ public function logQueries($enable = null)
144157
$this->_logQueries = $enable;
145158
}
146159

160+
/**
161+
* Enable/disable query logging
162+
*
163+
* @return $this
164+
*/
165+
public function enableQueryLogging()
166+
{
167+
$this->_logQueries = true;
168+
169+
return $this;
170+
}
171+
172+
/**
173+
* Disable query logging
174+
*
175+
* @return $this
176+
*/
177+
public function disableQueryLogging()
178+
{
179+
$this->_logQueries = false;
180+
181+
return $this;
182+
}
183+
184+
/**
185+
* Check if query logging is enabled.
186+
*
187+
* @return bool
188+
*/
189+
public function isQueryLoggingEnabled()
190+
{
191+
return $this->_logQueries;
192+
}
193+
147194
/**
148195
* Proxies the client's methods.
149196
*
@@ -183,7 +230,7 @@ public function __debugInfo()
183230
{
184231
return [
185232
'client' => $this->client(),
186-
'logger' => $this->logger(),
233+
'logger' => $this->getLogger(),
187234
'webservices' => array_keys($this->_webservices)
188235
];
189236
}

src/Model/EndpointRegistry.php

-1
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
class EndpointRegistry

src/Webservice/Webservice.php

-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
namespace Muffin\Webservice\Webservice;
44

55
use Cake\Core\App;
6-
use Cake\Core\Configure;
7-
use Cake\Datasource\ConnectionInterface;
86
use Cake\Utility\Inflector;
97
use Cake\Utility\Text;
108
use Muffin\Webservice\AbstractDriver;
119
use Muffin\Webservice\Exception\MissingEndpointSchemaException;
1210
use Muffin\Webservice\Exception\UnimplementedWebserviceMethodException;
1311
use Muffin\Webservice\Model\Endpoint;
1412
use Muffin\Webservice\Query;
15-
use Psr\Log\LoggerAwareInterface;
1613
use Psr\Log\LoggerInterface;
1714

1815
/**

tests/TestCase/Webservice/WebserviceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testExecuteLoggingWithLoggerEnabled()
110110
->expects($this->once())
111111
->method('debug');
112112

113-
$this->webservice->driver()->logQueries(true);
113+
$this->webservice->driver()->enableQueryLogging();
114114
$this->webservice->driver()->setLogger($logger);
115115

116116
$query = new Query($this->webservice, new Endpoint());

0 commit comments

Comments
 (0)