-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from markhuot/native-snapshots
wip native toSnapshot functionality
- Loading branch information
Showing
114 changed files
with
1,290 additions
and
1,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,4 +99,4 @@ it('loads the homepage') | |
->endBenchmark() | ||
->assertAllQueriesFasterThan(0.05); | ||
}); | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
# Database Assertions | ||
|
||
You can assert that particular rows appear in the database using database assertions. | ||
|
||
## assertDatabaseCount(string $tableName, int $expectedCount) | ||
Check that the given table contains the given number of rows. | ||
|
||
```php | ||
$this->assertDatabaseCount('{{%entries}}', 6); | ||
``` | ||
|
||
## assertDatabaseHas(string $tableName, array $condition) | ||
Check that the given table contains one or more matching rows | ||
for the given condition. | ||
|
||
```php | ||
$this->assertDatabaseHas('{{%content}}', ['title' => 'My Great Title']); | ||
``` | ||
|
||
## assertDatabaseMissing(string $tableName, array $condition) | ||
Check that the given table contains zero matching rows | ||
for the given condition. | ||
|
||
```php | ||
$this->assertDatabaseMissing('{{%content}}', ['title' => 'My Great Title']); | ||
``` | ||
|
||
## assertTrashed(craft\base\Element $element) | ||
Check that the given element has been trashed (soft deleted). | ||
|
||
```php | ||
$this->assertTrashed($entry); | ||
``` | ||
|
||
## assertNotTrashed(craft\base\Element $element) | ||
Check that the given element has not been trashed (soft deleted). | ||
|
||
```php | ||
$this->assertNotTrashed($entry); | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# CLI Commands | ||
|
||
## actionIndex() | ||
Run the Pest tests with `php craft pest`. This is a convienence function that internally calls the | ||
`pest/init` method and then `./vendor/bin/pest` executable. | ||
|
||
You may pass any pest options to this command by separating them with a `--`. For example, to filter | ||
down to a specific test you may run `php craft pest -- --filter="renders the homepage"`. | ||
|
||
## actionInit() | ||
Running `php craft pest/init` will create the `tests` directory, an associated `tests/Pest.php` file, a | ||
default `phpunit.xml` file, and a `modules/pest/seeders` directory. If any of these files or directories | ||
already exist they will be skipped. | ||
|
||
This command id idempotent and can be run multiple times without issue. If you even want to reset your | ||
setup to the default `Pest.php`, for example, you can delete your `Pest.php` and re-run `php craft pest/init` | ||
to have the file recreated. | ||
|
||
## actionSeed($seeder = NULL) | ||
Pest comes with a built-in database seeder that can be called in your own tests or via the command | ||
line. You may run the seeder with `php craft pest/seed`. By default, this will look for a class | ||
called \modules\pest\seeders\DatabaseSeeder. You may override this by passing a fully qualified class | ||
name as the first argument. For example, `php craft pest/seed \\modules\\pest\\seeders\\UserSeeder`. | ||
|
||
Seeders are __invoke-able classes. Inside the invoke method you are free to seed your database however | ||
you would like, although commonly you'll use factories to create your data. For example: | ||
|
||
```php | ||
class DatabaseSeeder | ||
{ | ||
public function __invoke() | ||
{ | ||
return \markhuot\craftpest\factories\Entry::factory()->count(10)->create(); | ||
} | ||
} | ||
``` | ||
|
||
You can override the defaults with the following environment variables, | ||
|
||
```bash | ||
PEST_SEEDER_NAMESPACE="\modules\pest\seeders" | ||
PEST_DEFAULT_SEEDER=DatabaseSeeder | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.