I have a concrete task to organize testing of my php-classes' methods using HTTP-requests in Python (function's parameters I get with $_POST
).
For example, I have two classes:
File A.php:
class A {
public function a(array $params) {
return "Class A params:<br><pre>".print_r($params, TRUE)."</pre>";
}
}
File B.php:
class B {
public function b(string $param) {
return "Class b: $param";
}
}
My idea is to create directory test
with the file structure:
| index.php
| style.css
|
|-----classA
| index.php
|
|-----classB
| index.php
I think to send python HTTP-requests to main index.php where I search for parameters and then do something like:
if ( isset($_POST['classA']['method_a']) ) {
$a_obj = new A();
$params = $_POST['classA']['method_a'];
$a_obj->a($params);
}
if ( isset($_POST['classB']['method_b']) ) {
$b_obj = new B();
$param = $_POST['classB']['method_b'];
$b_obj->b($param);
}
So, my question. I think my idea is not correct beacuse it seems strange, does it? Also I thought to create no index-file in test root but send request for special folder (like classA/classB folders above). But in that case I get a lot of URLs (it's not very well), so I don't know what to do. I'm confused.
Can somebody advise me a decision?
Aucun commentaire:
Enregistrer un commentaire