Skip to content

Commit 72f4e05

Browse files
authored
Merge pull request #66 from UseMuffin/cake-3.6
Update for Cake 3.6.0.
2 parents e54b4e8 + 06094b5 commit 72f4e05

File tree

10 files changed

+33
-34
lines changed

10 files changed

+33
-34
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: php
22

33
php:
4-
- 7.1
54
- 7.0
5+
- 7.2
6+
- 7.1
67
- 5.6
7-
- 5.5
88

99
dist: trusty
1010

@@ -27,7 +27,7 @@ matrix:
2727
before_script:
2828
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
2929

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

3333
script:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"require": {
4242
},
4343
"require-dev": {
44-
"cakephp/cakephp": ">=3.2",
45-
"cakephp/cakephp-codesniffer": "2.*",
46-
"phpunit/phpunit": "<6.0"
44+
"cakephp/cakephp": "^3.6",
45+
"cakephp/cakephp-codesniffer": "^3.0",
46+
"phpunit/phpunit": "5.7.14|^6.0"
4747
},
4848
"autoload": {
4949
"psr-4": {

src/AbstractDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class AbstractDriver implements LoggerAwareInterface
4444
public function __construct($config = [])
4545
{
4646
if (!empty($config)) {
47-
$this->config($config);
47+
$this->setConfig($config);
4848
}
4949

5050
$this->initialize();

src/Marshaller.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function one(array $data, array $options = [])
5555
$resourceClass = $this->_endpoint->resourceClass();
5656
/* @var \Muffin\Webservice\Model\Resource $entity */
5757
$entity = new $resourceClass();
58-
$entity->source($this->_endpoint->registryAlias());
58+
$entity->setSource($this->_endpoint->registryAlias());
5959

6060
if (isset($options['accessibleFields'])) {
6161
foreach ((array)$options['accessibleFields'] as $key => $value) {
@@ -79,7 +79,7 @@ public function one(array $data, array $options = [])
7979

8080
if (!isset($options['fieldList'])) {
8181
$entity->set($properties);
82-
$entity->errors($errors);
82+
$entity->setErrors($errors);
8383

8484
return $entity;
8585
}
@@ -106,22 +106,23 @@ public function one(array $data, array $options = [])
106106
*/
107107
protected function _validate($data, $options, $isNew)
108108
{
109-
if (!$options['validate']) {
110-
return [];
111-
}
109+
$validator = null;
110+
112111
if ($options['validate'] === true) {
113-
$options['validate'] = $this->_endpoint->validator('default');
112+
$validator = $this->_endpoint->getValidator('default');
113+
} elseif (is_string($options['validate'])) {
114+
$validator = $this->_endpoint->getValidator($options['validate']);
115+
} elseif (is_object($options['validate'])) {
116+
$validator = $options['validate'];
114117
}
115-
if (is_string($options['validate'])) {
116-
$options['validate'] = $this->_endpoint->validator($options['validate']);
117-
}
118-
if (!is_object($options['validate'])) {
118+
119+
if ($validator === null) {
119120
throw new RuntimeException(
120121
sprintf('validate must be a boolean, a string or an object. Got %s.', gettype($options['validate']))
121122
);
122123
}
123124

124-
return $options['validate']->errors($data, $isNew);
125+
return $validator->errors($data, $isNew);
125126
}
126127

127128
/**

src/Model/Endpoint.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
use Cake\Event\EventDispatcherTrait;
1515
use Cake\Event\EventListenerInterface;
1616
use Cake\Event\EventManager;
17-
use Cake\Network\Exception\NotImplementedException;
1817
use Cake\Utility\Inflector;
1918
use Cake\Validation\ValidatorAwareTrait;
2019
use Muffin\Webservice\Exception\MissingResourceClassException;
2120
use Muffin\Webservice\Exception\UnexpectedDriverException;
2221
use Muffin\Webservice\Marshaller;
2322
use Muffin\Webservice\Query;
2423
use Muffin\Webservice\Schema;
25-
use Muffin\Webservice\StreamQuery;
2624

2725
/**
2826
* The table equivalent of a webservice endpoint
@@ -839,11 +837,11 @@ public function save(EntityInterface $resource, $options = [])
839837
'checkExisting' => false,
840838
]);
841839

842-
if ($resource->errors()) {
840+
if ($resource->getErrors()) {
843841
return false;
844842
}
845843

846-
if ($resource->isNew() === false && !$resource->dirty()) {
844+
if ($resource->isNew() === false && !$resource->isDirty()) {
847845
return $resource;
848846
}
849847

src/Model/Resource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(array $properties = [], array $options = [])
4141
];
4242

4343
if (!empty($options['source'])) {
44-
$this->source($options['source']);
44+
$this->setSource($options['source']);
4545
}
4646

4747
if ($options['markNew'] !== null) {

src/Query.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function clause($name)
175175
public function endpoint(Endpoint $endpoint = null)
176176
{
177177
if ($endpoint === null) {
178-
return $this->repository();
178+
return $this->getRepository();
179179
}
180180

181181
$this->repository($endpoint);
@@ -206,7 +206,7 @@ public function webservice(WebserviceInterface $webservice = null)
206206
*/
207207
public function find($finder, array $options = [])
208208
{
209-
return $this->repository()->callFinder($finder, $this, $options);
209+
return $this->getRepository()->callFinder($finder, $this, $options);
210210
}
211211

212212
/**
@@ -224,7 +224,7 @@ public function firstOrFail()
224224
}
225225
throw new RecordNotFoundException(sprintf(
226226
'Record not found in endpoint "%s"',
227-
$this->repository()->endpoint()
227+
$this->getRepository()->endpoint()
228228
));
229229
}
230230

@@ -466,12 +466,12 @@ public function first()
466466
public function triggerBeforeFind()
467467
{
468468
if (!$this->_beforeFindFired && $this->action() === self::ACTION_READ) {
469-
$endpoint = $this->repository();
469+
$endpoint = $this->getRepository();
470470
$this->_beforeFindFired = true;
471471
$endpoint->dispatchEvent('Model.beforeFind', [
472472
$this,
473473
new ArrayObject($this->_options),
474-
!$this->eagerLoaded()
474+
!$this->isEagerLoaded()
475475
]);
476476
}
477477
}

tests/TestCase/Model/ResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testSoureConstruct()
2323
$resource = new Resource([], [
2424
'source' => $endpoint
2525
]);
26-
$this->assertEquals($endpoint, $resource->source());
26+
$this->assertEquals($endpoint, $resource->getSource());
2727
}
2828

2929
public function testConstructUseSettersOff()

tests/TestCase/Webservice/WebserviceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function testCreateResource()
173173

174174
$this->assertInstanceOf('\Muffin\Webservice\Model\Resource', $resource);
175175
$this->assertFalse($resource->isNew());
176-
$this->assertFalse($resource->dirty());
176+
$this->assertFalse($resource->isDirty());
177177
}
178178

179179
public function testTransformResults()

tests/bootstrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
'defaults' => 'php'
6969
]);
7070

71-
Cache::config([
71+
Cache::setConfig([
7272
'_cake_core_' => [
7373
'engine' => 'File',
7474
'prefix' => 'cake_core_',
@@ -97,10 +97,10 @@
9797
];
9898

9999
// Use the test connection for 'debug_kit' as well.
100-
ConnectionManager::config('test', $config);
101-
ConnectionManager::config('test_webservice', $config);
100+
ConnectionManager::setConfig('test', $config);
101+
ConnectionManager::setConfig('test_webservice', $config);
102102

103-
Log::config([
103+
Log::setConfig([
104104
'debug' => [
105105
'engine' => 'Cake\Log\Engine\FileLog',
106106
'levels' => ['notice', 'info', 'debug'],

0 commit comments

Comments
 (0)