Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b45e9c0
Use Rust FFI: Consumer
tienvx Dec 23, 2022
849efd5
Merge branch 'master' into use-rust-ffi-consumer
tienvx Jan 11, 2023
e1d49cc
Remove method BuilderInterface::writePact
tienvx Jan 11, 2023
0d7fe0a
Remove CHANGELOG.md. Add '@internal' to classes are not supposed to b…
tienvx Jan 15, 2023
0812b31
Add missing return type to method Matcher::regex
tienvx Jan 15, 2023
cf5144b
Add more details to UPGRADE-9.0.md
tienvx Jan 15, 2023
d20f1f5
Revert multiple values support in header and query parameter
tienvx Jan 16, 2023
7d57b25
Merge branch 'master' into use-rust-ffi-consumer
Feb 14, 2023
bb256ef
Support multiple values in header and query parameter
tienvx Mar 1, 2023
d6a9d0d
Update pact ffi library
tienvx Mar 1, 2023
ca46297
Rename method getCode to getHeader
tienvx Mar 2, 2023
39718b9
Revert breaking change that require to call createMockServer manually
tienvx Mar 12, 2023
ddc46e5
Remove composer/semver
tienvx Mar 2, 2023
5dae03a
Make sure every value of header and query parameter is string
tienvx Mar 14, 2023
52e9a99
Move exception message to exception
tienvx Mar 14, 2023
bff0f9b
Extract method getSpecification() to check for supporting plugin
tienvx Mar 14, 2023
312c45c
Extract, change visibility, and move methods to abstract class to sup…
tienvx Mar 14, 2023
e7675e6
Use Rust FFI: Support multiple provider states with params for intera…
tienvx Mar 7, 2023
1e0b409
Fix provider state without params not added
tienvx Mar 16, 2023
47b0a81
Remove jsonSerialize methods
tienvx Jan 5, 2023
2754f47
Rename pact to driver
tienvx Mar 17, 2023
18b85b2
Move log level config to trait for reusing
tienvx Mar 23, 2023
5a4b15f
Allow mock server write pact file
tienvx Mar 23, 2023
072cc93
Merge branch 'master' into use-rust-ffi-consumer
tienvx May 3, 2023
29b33ec
Revert removing semver
tienvx May 3, 2023
a0302bc
Extract services and helpers
tienvx May 4, 2023
7fbc58d
Make PR smaller
tienvx May 4, 2023
ff2120f
Extract drivers and factories
tienvx May 4, 2023
420f4c2
Extract set up method
tienvx May 5, 2023
7f472fe
Simplify default interaction registry factory
tienvx May 5, 2023
c87dd62
Move methods from AbstractDriver to InteractionDriver and rename
tienvx May 5, 2023
53cef3d
Group assertions together for better readability
tienvx May 5, 2023
d5a4b83
Remove condition to make code shorter
tienvx May 5, 2023
6cf8128
Update ffi library to 0.4.4
tienvx May 5, 2023
156f989
Remove not useful annotation
tienvx May 5, 2023
bd8b751
Rename ffi service and move it to FFI namespace
tienvx May 6, 2023
d41e1ac
Assign result to variable before asserting
tienvx May 8, 2023
cc7f14c
Change type hint from 'mixed' to 'string|array|null'
tienvx May 8, 2023
dfaa021
Add @throws annotation to setPactFileWriteMode() method declaration b…
tienvx May 8, 2023
693daad
Rename FFI Proxy to Client
tienvx May 8, 2023
d960221
Extract interaction part drivers
tienvx May 8, 2023
770e6e0
Extract interaction contents drivers
tienvx May 9, 2023
29f7b4c
Extract interaction part traits for reusing
tienvx May 9, 2023
768b772
Allow sub-class access properties
tienvx May 9, 2023
a96c56a
Move common code back to MockServer for reusing. Remove methods from …
tienvx May 9, 2023
264018a
Move code from registry to driver
tienvx May 9, 2023
3a3afda
Switch term 'Driver' <--> 'Registry'
tienvx May 10, 2023
02b7fc3
Merge branch 'master' into use-rust-ffi-consumer
tienvx May 11, 2023
1d6d39e
Inject driver factory into builder
tienvx May 12, 2023
f844be0
Revert namespace change
tienvx May 12, 2023
d5d14e8
Use Rust FFI: Message Consumer
tienvx Dec 28, 2022
6aad456
Use Rust FFI: Provider
tienvx Jan 2, 2023
e96453f
Use Rust FFI: Stub Server
tienvx Jan 3, 2023
6d19fa8
Use Rust FFI: Offload process
tienvx Jan 3, 2023
9dbbde1
Fix stub server always load pact files from pact broker
tienvx May 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert breaking change that require to call createMockServer manually
  • Loading branch information
tienvx committed Mar 12, 2023
commit 39718b9ca5ee7782b451ef2d2474fca3d3d26b1e
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,7 @@ $builder
->given('a person exists')
->uponReceiving('a get request to /hello/{name}')
->with($request)
->willRespondWith($response); // This has to be last. This is what makes an API request to the Mock Server to set the interaction.
```

### Start the Mock Server

Mock server need to be started manually

```php
$builder->createMockServer();
->willRespondWith($response); // This has to be last. This is what makes FFI calls to register the interaction and start the mock server.
```

### Make the Request
Expand Down
19 changes: 1 addition & 18 deletions UPGRADE-9.0.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
UPGRADE FROM 8.x to 9.0
=======================

* Interaction Builder
* It's now required to call `PhpPact\Consumer\InteractionBuilder::createMockServer` manually

Example Usage:
```php
$builder = new InteractionBuilder($config);
$builder
->given('a person exists')
->uponReceiving('a get request to /hello/{name}')
->with($request)
->willRespondWith($response);
$builder->createMockServer();

$apiClient->sendRequest();

$this->assertTrue($builder->verify());
```

* Environment Variables
* These environment variables can be removed:
* PACT_CORS
* PACT_MOCK_SERVER_HEALTH_CHECK_TIMEOUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function testGetGoodbyeString()
->uponReceiving('A get request to /goodbye/{name}')
->with($request)
->willRespondWith($response);
$builder->createMockServer();

$service = new HttpClientService($config->getBaseUri());
$result = $service->getGoodbyeString('Bob');
Expand Down
3 changes: 1 addition & 2 deletions example/tests/Consumer/Service/ConsumerServiceHelloTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function testGetHelloString()
$builder
->uponReceiving('A get request to /hello/{name}')
->with($request)
->willRespondWith($response); // This has to be last. This is what makes a FFI call to the Mock Server to set the interaction.
$builder->createMockServer();
->willRespondWith($response); // This has to be last. This is what makes FFI calls to register the interaction and start the mock server.

$service = new HttpClientService($config->getBaseUri()); // Pass in the URL to the Mock Server.
$result = $service->getHelloString('Bob'); // Make the real API request against the Mock Server.
Expand Down
8 changes: 0 additions & 8 deletions src/PhpPact/Consumer/InteractionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,4 @@ public function verify(): bool
{
return $this->pact->verifyInteractions();
}

/**
* Create mock server before verifying.
*/
public function createMockServer(): void
{
$this->pact->createMockServer();
}
}
5 changes: 3 additions & 2 deletions src/PhpPact/Consumer/Model/Pact.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(private MockServerConfigInterface $config)
->withSpecification();
}

public function createMockServer(): void
private function createMockServer(): void
{
$port = $this->ffi->pactffi_create_mock_server_for_transport(
$this->id,
Expand Down Expand Up @@ -83,7 +83,8 @@ public function registerInteraction(Interaction $interaction): bool
->given($interaction)
->uponReceiving($interaction)
->with($interaction)
->willRespondWith($interaction);
->willRespondWith($interaction)
->createMockServer();

return true;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/PhpPact/Consumer/InteractionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public function testSimpleGet()
->addHeader('Content-Type', 'application/json');

$builder = new InteractionBuilder(new MockServerEnvConfig());
$result = $builder
$builder
->given('A test request.')
->uponReceiving('A test response.')
->with($request)
->willRespondWith($response);

$this->assertTrue($result);
$this->assertFalse($builder->verify());
}

/**
Expand Down Expand Up @@ -74,13 +74,13 @@ public function testPostWithBody()
]);

$builder = new InteractionBuilder(new MockServerEnvConfig());
$result = $builder
$builder
->given('A test request.')
->uponReceiving('A test response.')
->with($request)
->willRespondWith($response);

$this->assertTrue($result);
$this->assertFalse($builder->verify());
}

/**
Expand Down Expand Up @@ -108,12 +108,12 @@ public function testBuildWithEachLikeMatcher()
]);

$builder = new InteractionBuilder(new MockServerEnvConfig());
$result = $builder
$builder
->given('A test request.')
->uponReceiving('A test response.')
->with($request)
->willRespondWith($response);

$this->assertTrue($result);
$this->assertFalse($builder->verify());
}
}