New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query param matcher API #31
Conversation
4b65243
to
359f6b3
Compare
I know that a "partial match" would be handy because it could cut down on some typing. But the basic grammar is enough to start using it. |
Can you elaborate? |
I'm primarily a Ruby developer. In RSpec, one of the Ruby testing frameworks, you can "partially match" a hash (in PHP, an associative array) with something like this: require "rspec/autorun"
class Demo
def initialize(arg)
@arg = arg
end
end
RSpec.describe "hash_including" do
it "partially matches hashes" do
hash = {:key => "value", :key2 => "value2"}
expect(Demo).to receive(:new).with hash_including(:key => "value")
Demo.new(hash)
end
end This spec checks to make sure that I was picturing something similar for checking query parameters in this context. Something like: $this->http->mock
->when()
->methodIs("GET")
->pathIs("/my/test/path")
->queryContains(array("param1" => "test1", "param2" => "test2"))
->then()->body("{}")->statusCode(200)
->end(); So you could call to I see this being useful when you're making a client that always sets a particular parameter like $this->http->mock
->when()
->methodIs("GET")
->pathIs("/my/test/path")
->queryParamIs("param1", "test1")
->queryParamIs("param2", "test2")
->then()->body("{}")->statusCode(200)
->end(); Does that make sense? |
Understood. So we could add a |
Ping! Can you have a look again, if that’s what you need? |
7b5a539
to
2532b6d
Compare
9dd8df8
to
a6cb7fa
Compare
This looks fantastic! Thanks for taking the time to add it. 👍 |
Should allow to check for the existence of query params. Q: should there be an API to do a full match?