Skip to content

Commit 7b91ebf

Browse files
committed
Merge branch 'master' into 9.x
2 parents c0b3e41 + 3a25ad3 commit 7b91ebf

17 files changed

+6
-786
lines changed

README.md

-196
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Laravel-specific Testing Helpers and Assertions.
7474
- [emulateLocal](#emulatelocal)
7575
- [emulateProduction](#emulateproduction)
7676
- [emulateEnvironment](#emulateenvironment)
77-
- [isTravis](#istravis)
7877

7978
## Available assertions
8079

@@ -88,21 +87,6 @@ Laravel-specific Testing Helpers and Assertions.
8887
- [assertDatabaseMissingTable](#assertdatabasemissingtable)
8988
- [assertDatabaseHasMany](#assertdatabasehasmany)
9089
- [assertDatabaseMissingMany](#assertdatabasemissingmany)
91-
- [EloquentAsserts](#eloquentasserts)
92-
- [assertEloquentTableEquals](#asserteloquenttableequals)
93-
- [assertEloquentTableNotEquals](#asserteloquenttablenotequals)
94-
- [assertEloquentIsIncrementing](#asserteloquentisincrementing)
95-
- [assertEloquentIsNotIncrementing](#asserteloquentisnotincrementing)
96-
- [assertEloquentFillableEquals](#asserteloquentfillableequals)
97-
- [assertEloquentFillableNotEquals](#asserteloquentfillablenotequals)
98-
- [assertEloquentDatesEquals](#asserteloquentdatesequals)
99-
- [assertEloquentDatesNotEquals](#asserteloquentdatesnotequals)
100-
- [assertEloquentTouchesEquals](#asserteloquenttouchesequals)
101-
- [assertEloquentTouchesNotEquals](#asserteloquenttouchesnotequals)
102-
- [assertEloquentHasMany](#asserteloquenthasmany)
103-
- [assertEloquentHasCreateFor](#asserteloquenthascreatefor)
104-
- [assertEloquentHasCreateManyFor](#asserteloquenthascreatemanyfor)
105-
- [assertEloquentBelongsTo](#asserteloquentbelongsto)
10690
- [ExceptionAsserts](#exceptionasserts)
10791
- [willSeeException](#willseeexception)
10892
- [FilesystemAsserts](#filesystemasserts)
@@ -161,16 +145,6 @@ Emulate that application is running on the given environment:
161145
$this->emulateEnvironment('demo');
162146
```
163147

164-
#### `isTravis()`
165-
166-
Check whether the application is running on Travis or not:
167-
168-
```php
169-
$this->isTravis();
170-
171-
// true
172-
```
173-
174148
## Assertions
175149

176150
### CollectionAsserts
@@ -232,176 +206,6 @@ $this->assertDatabaseMissingMany('posts', [
232206
]);
233207
```
234208

235-
### EloquentAsserts
236-
237-
#### `assertEloquentTableEquals()`
238-
239-
Assert that the model's table name equals to the given value:
240-
241-
```php
242-
$this->assertEloquentTableEquals(User::class, 'users');
243-
```
244-
245-
#### `assertEloquentTableNotEquals()`
246-
247-
Assert that the model's table name doesn't equal to the given value:
248-
249-
```php
250-
$this->assertEloquentTableNotEquals(User::class, 'posts');
251-
```
252-
253-
#### `assertEloquentIsIncrementing()`
254-
255-
Assert that the model's primary key is incrementing:
256-
257-
```php
258-
$this->assertEloquentIsIncrementing(Post::class);
259-
```
260-
261-
#### `assertEloquentIsNotIncrementing()`
262-
263-
Assert that the model's primary key is not incrementing:
264-
265-
```php
266-
$this->assertEloquentIsNotIncrementing(Category::class);
267-
```
268-
269-
#### `assertEloquentFillableEquals()`
270-
271-
Assert that the model's `fillable` field equals to the given value:
272-
273-
```php
274-
$this->assertEloquentFillableEquals(Post::class, ['title', 'publish_at']);
275-
```
276-
277-
#### `assertEloquentFillableNotEquals()`
278-
279-
Assert that the model's `fillable` field doesn't equal to the given value:
280-
281-
```php
282-
$this->assertEloquentFillableNotEquals(Post::class, ['title', 'body', 'publish_at']);
283-
```
284-
285-
#### `assertEloquentDatesEquals()`
286-
287-
Assert that the model's `dates` field equals to the given value:
288-
289-
```php
290-
$this->assertEloquentDatesEquals(Post::class, ['publish_at', 'created_at', 'updated_at']);
291-
```
292-
293-
#### `assertEloquentDatesNotEquals()`
294-
295-
Assert that the model's `dates` field doesn't equal to the given value:
296-
297-
```php
298-
$this->assertEloquentDatesNotEquals(Post::class, ['publish_at']);
299-
```
300-
301-
#### `assertEloquentTouchesEquals()`
302-
303-
Assert that the model's `touches` field equals to the given value:
304-
305-
```php
306-
$this->assertEloquentTouchesEquals(Comment::class, ['post']);
307-
```
308-
309-
#### `assertEloquentTouchesNotEquals()`
310-
311-
Assert that the model's `touches` field doesn't equal to the given value:
312-
313-
```php
314-
$this->assertEloquentTouchesNotEquals(Comment::class, ['user']);
315-
```
316-
317-
#### `assertEloquentHasMany()`
318-
319-
> NOTE: To use this assertion, you have to create model factories for both classes.
320-
321-
Assert that the model has the given `HasMany` relation:
322-
323-
```php
324-
$this->assertEloquentHasMany(Post::class, 'comments');
325-
```
326-
327-
Assuming that `Post` class has `comments` relation:
328-
329-
```php
330-
class Post extends Model
331-
{
332-
public function comments()
333-
{
334-
return $this->hasMany(Comment::class);
335-
}
336-
}
337-
```
338-
339-
#### `assertEloquentHasCreateFor()`
340-
341-
> NOTE: To use this assertion, you have to create model factories for both classes.
342-
343-
Assert that the model has `create` method for the given `HasMany` relation:
344-
345-
```php
346-
$this->assertEloquentHasCreateFor(Post::class, 'comments');
347-
```
348-
349-
Assuming that `Post` class has `createComment()` method:
350-
351-
```php
352-
class Post extends Model
353-
{
354-
public function createComment(array $attributes)
355-
{
356-
return $this->comments()->create($attributes);
357-
}
358-
}
359-
```
360-
361-
#### `assertEloquentHasCreateManyFor()`
362-
363-
> NOTE: To use this assertion, you have to create model factories for both classes.
364-
365-
Assert that the model has `createMany` method for the given `HasMany` relation:
366-
367-
```php
368-
$this->assertEloquentHasCreateManyFor(Post::class, 'comments');
369-
```
370-
371-
Assuming that `Post` class has `createManyComments()` method:
372-
373-
```php
374-
class Post extends Model
375-
{
376-
public function createManyComments(array $comments)
377-
{
378-
return $this->comments()->createMany($comments);
379-
}
380-
}
381-
```
382-
383-
#### `assertEloquentBelongsTo()`
384-
385-
> NOTE: To use this assertion, you have to create model factories for both classes.
386-
387-
Assert that the model has the given `BelongsTo` relation:
388-
389-
```php
390-
$this->assertEloquentBelongsTo(Comment::class, 'post');
391-
```
392-
393-
Assuming that `Comment` class has `post` relation:
394-
395-
```php
396-
class Comment extends Model
397-
{
398-
public function post()
399-
{
400-
return $this->belongsTo(Post::class);
401-
}
402-
}
403-
```
404-
405209
### ExceptionAsserts
406210

407211
#### `willSeeException()`

src/Asserts/CollectionAsserts.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ trait CollectionAsserts
1111
*/
1212
protected function assertCollectionsEqual(Collection $collection1, Collection $collection2, string $key): void
1313
{
14-
$this->assertEquals(
15-
$collection1->pluck($key)->sort()->values(),
16-
$collection2->pluck($key)->sort()->values(),
14+
$this->assertEqualsCanonicalizing(
15+
$collection1->pluck($key),
16+
$collection2->pluck($key),
1717
'Failed asserting that collections are equal.',
1818
);
1919
}
@@ -23,9 +23,9 @@ protected function assertCollectionsEqual(Collection $collection1, Collection $c
2323
*/
2424
protected function assertCollectionsNotEqual(Collection $collection1, Collection $collection2, string $key): void
2525
{
26-
$this->assertNotEquals(
27-
$collection1->pluck($key)->sort()->values(),
28-
$collection2->pluck($key)->sort()->values(),
26+
$this->assertNotEqualsCanonicalizing(
27+
$collection1->pluck($key),
28+
$collection2->pluck($key),
2929
'Failed asserting that collections are not equal.',
3030
);
3131
}

0 commit comments

Comments
 (0)