Skip to content

Commit 67be2c9

Browse files
committed
Updated dependencies and tests
1 parent 8285c36 commit 67be2c9

6 files changed

Lines changed: 35 additions & 43 deletions

File tree

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
],
1010
"license": "MIT",
1111
"require": {
12-
"php": ">=7.0.0",
12+
"php": ">=7.1.0",
13+
"ext-fileinfo": "*",
1314
"ext-soap": "*",
14-
"nesbot/carbon": "^1.20",
15+
"nesbot/carbon": "^2.0",
1516
"doctrine/inflector": "~1.0"
1617
},
1718
"require-dev": {
18-
"phpunit/phpunit": "^5.2",
19-
"mockery/mockery": "^0.9.4",
19+
"phpunit/phpunit": "^8.5",
20+
"mockery/mockery": "^1.3",
2021
"symfony/var-dumper": "^5.0"
2122
},
2223
"autoload": {

tests/KeyCollectionTest.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
use Pace\Model;
44
use Pace\KeyCollection;
5+
use PHPUnit\Framework\TestCase;
56

6-
class KeyCollectionTest extends PHPUnit_Framework_TestCase
7+
class KeyCollectionTest extends TestCase
78
{
8-
public function tearDown()
9+
public function tearDown(): void
910
{
1011
Mockery::close();
1112
}
@@ -16,7 +17,7 @@ public function testAll()
1617
$collection = new KeyCollection($model, [1, 2, 3]);
1718
$model->shouldReceive('read')->times(3)->andReturnSelf();
1819
$all = $collection->all();
19-
$this->assertInternalType('array', $all);
20+
$this->assertIsArray($all);
2021
$this->assertContainsOnlyInstancesOf(Model::class, $all);
2122
}
2223

@@ -66,13 +67,11 @@ public function testLast()
6667
$this->assertInstanceOf(Model::class, $collection->last());
6768
}
6869

69-
/**
70-
* @expectedException \OutOfBoundsException
71-
*/
7270
public function testGetThrowsOutOfBoundsException()
7371
{
7472
$model = Mockery::mock(Model::class);
7573
$collection = new KeyCollection($model, [1]);
74+
$this->expectException(OutOfBoundsException::class);
7675
$collection->get(2);
7776
}
7877

@@ -102,7 +101,7 @@ public function testJsonSerializable()
102101
$model->shouldReceive('read')->with(5)->once()->andReturnSelf();
103102
$array = $collection->jsonSerialize();
104103
$this->assertInstanceOf('JsonSerializable', $collection);
105-
$this->assertInternalType('array', $array);
104+
$this->assertIsArray($array);
106105
$this->assertContainsOnlyInstancesOf('JsonSerializable', $array);
107106
}
108107

@@ -116,23 +115,19 @@ public function testArrayAccess()
116115
$this->assertInstanceOf(Model::class, $collection[8]);
117116
}
118117

119-
/**
120-
* @expectedException \RuntimeException
121-
*/
122118
public function testImmutableSet()
123119
{
124120
$model = Mockery::mock(Model::class);
125121
$collection = new KeyCollection($model, []);
122+
$this->expectException(RuntimeException::class);
126123
$collection[0] = 1;
127124
}
128125

129-
/**
130-
* @expectedException \RuntimeException
131-
*/
132126
public function testImmutableUnset()
133127
{
134128
$model = Mockery::mock(Model::class);
135129
$collection = new KeyCollection($model, [1]);
130+
$this->expectException(RuntimeException::class);
136131
unset($collection[1]);
137132
}
138133

tests/ModelAttachmentsTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
use Pace\Model;
44
use Pace\Client;
5+
use PHPUnit\Framework\TestCase;
56
use Pace\Services\AttachmentService;
67

7-
class ModelAttachmentsTest extends PHPUnit_Framework_TestCase
8+
class ModelAttachmentsTest extends TestCase
89
{
9-
public function tearDown()
10+
public function tearDown(): void
1011
{
1112
Mockery::close();
1213
}
1314

14-
/**
15-
* @expectedException \BadMethodCallException
16-
*/
1715
public function testGetContentOnlyAvailableOnFileAttachment()
1816
{
1917
$client = Mockery::mock(Client::class);
2018
$model = new Model($client, 'Job');
19+
$this->expectException(BadMethodCallException::class);
2120
$model->getContent();
2221
}
2322

tests/ModelTest.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
use Pace\Client;
55
use Pace\KeyCollection;
66
use Pace\XPath\Builder;
7+
use PHPUnit\Framework\TestCase;
8+
use Pace\ModelNotFoundException;
79

8-
class ModelTest extends PHPUnit_Framework_TestCase
10+
class ModelTest extends TestCase
911
{
10-
public function tearDown()
12+
public function tearDown(): void
1113
{
1214
Mockery::close();
1315
}
1416

15-
/**
16-
* @expectedException \InvalidArgumentException
17-
*/
1817
public function testCannotBeConstructedWithCamelCase()
1918
{
2019
$client = Mockery::mock(Client::class);
20+
$this->expectException(InvalidArgumentException::class);
2121
new Model($client, 'salesPerson');
2222
}
2323

@@ -48,14 +48,12 @@ public function testPrimaryKeysCanBeSpecifiedOrGuessed()
4848
$this->assertEquals($model->key('foo'), 999);
4949
}
5050

51-
/**
52-
* @expectedException UnexpectedValueException
53-
*/
5451
public function testExceptionIsThrownForEmptyKey()
5552
{
5653
$client = Mockery::mock(Client::class);
5754
$model = new Model($client, 'CSR');
5855
$model->id = 0;
56+
$this->expectException(UnexpectedValueException::class);
5957
$model->key();
6058
}
6159

@@ -88,14 +86,12 @@ public function testReadOrFail()
8886
$this->assertInstanceOf(Model::class, $model->readOrFail(5));
8987
}
9088

91-
/**
92-
* @expectedException Pace\ModelNotFoundException
93-
*/
9489
public function testReadOrFailThrowsModelNotFoundException()
9590
{
9691
$client = Mockery::mock(Client::class);
9792
$client->shouldReceive('readObject')->once()->with('SalesPerson', 5)->andReturn(null);
9893
$model = new Model($client, 'SalesPerson');
94+
$this->expectException(ModelNotFoundException::class);
9995
$model->readOrFail(5);
10096
}
10197

@@ -325,7 +321,9 @@ public function testDuplicateWithNewKey()
325321
$model = new Model($client, 'ShipVia', $attributes);
326322
$model->exists = true;
327323
$model->description = 'Express';
328-
$model->duplicate(5002);
324+
$newModel = $model->duplicate(5002);
325+
$this->assertInstanceOf(Model::class, $newModel);
326+
$this->assertEquals(5002, $newModel->id);
329327
}
330328

331329
public function testMagicBelongsTo()

tests/TypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use Pace\Type;
4+
use PHPUnit\Framework\TestCase;
45

5-
class TypeTest extends PHPUnit_Framework_TestCase
6+
class TypeTest extends TestCase
67
{
78
public function testCamelize()
89
{

tests/XPath/BuilderTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
use Pace\Model;
44
use Pace\KeyCollection;
55
use Pace\XPath\Builder;
6+
use PHPUnit\Framework\TestCase;
7+
use Pace\ModelNotFoundException;
68

7-
class BuilderTest extends PHPUnit_Framework_TestCase
9+
class BuilderTest extends TestCase
810
{
9-
public function tearDown()
11+
public function tearDown(): void
1012
{
1113
Mockery::close();
1214
}
1315

14-
/**
15-
* @expectedException InvalidArgumentException
16-
*/
1716
public function testExceptionIsThrownForInvalidOperator()
1817
{
18+
$this->expectException(InvalidArgumentException::class);
1919
(new Builder)->filter('@id', '<>', 99);
2020
}
2121

@@ -146,16 +146,14 @@ public function testFirstOrFail()
146146
$this->assertInstanceOf(Model::class, (new Builder($model))->firstOrFail());
147147
}
148148

149-
/**
150-
* @expectedException \Pace\ModelNotFoundException
151-
*/
152149
public function testFirstOrFailThrowsModelNotFoundException()
153150
{
154151
$model = Mockery::mock(Model::class);
155152
$collection = Mockery::mock(KeyCollection::class);
156153
$model->shouldReceive('find')->once()->andReturn($collection);
157154
$model->shouldReceive('getType')->once()->andReturn('Job');
158155
$collection->shouldReceive('first')->once()->andReturnNull();
156+
$this->expectException(ModelNotFoundException::class);
159157
(new Builder($model))->firstOrFail();
160158
}
161159
}

0 commit comments

Comments
 (0)