Skip to content

Commit

Permalink
Merge pull request #13 from JonPurvis/update/testing-changes
Browse files Browse the repository at this point in the history
stronger tests
  • Loading branch information
JonPurvis authored Aug 6, 2023
2 parents 357f7b8 + c3677aa commit b6a981f
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 197 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,19 @@ beforeEach(function () {
$this->fake->addProvider(new Stripe($this->fake));
});

it('shows an example', function () {
$this->fake->stripeConnectAccountId() // acct_xBXg7yyrSyQVbsjM
it('generates a well structured stripe account id', function () {
expect($this->fake->stripeConnectAccountId())->toStartWith('acct_')->toHaveLength(21)->toBeString();
});
```

### PHPUnit
```php

private Generator $faker;

protected function setUp(): void
public function testGeneratesWellStructuredStripeAccountId()
{
$faker = Factory::create();
$faker->addProvider(new Stripe($faker));

$this->faker = $faker;
}

public function testShowExample()
{
$this->faker->stripeConnectAccountId() // acct_xBXg7yyrSyQVbsjM
$this->assertStringStartsWith('acct_', $faker->stripeConnectAccountId());
}
```

Expand All @@ -223,6 +215,10 @@ public function definition(): array
{
$this->faker->addProvider(new Stripe($this->faker));

$this->faker->stripeConnectAccountId() // acct_xBXg7yyrSyQVbsjM
return [
'id' => $this->faker->stripeConnectAccountId(),
'name' => 'John Doe',
'email' => 'john.doe@testing.co.uk'
];
}
```
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
],
"require": {
"php": "^8.1",
"fakerphp/faker": "^1.10"
"fakerphp/faker": "^1.23"
},
"require-dev": {
"pestphp/pest": "^2.6",
"pestphp/pest": "^2.12",
"pestphp/pest-plugin-faker": "^2.0"
},
"autoload": {
Expand Down
9 changes: 9 additions & 0 deletions tests/ArchitectureTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Faker\Provider\Base;
use Faker\Provider\Stripe;

test('provider')
->expect(Stripe::class)
->toExtend(Base::class)
->toOnlyUse(Base::class);
Loading

0 comments on commit b6a981f

Please sign in to comment.