chesslablab/chess-server

Write a functional test to check the /legal command

programarivm opened this issue ยท 7 comments

Create a new file called tests/functional/LegalCommandTest.php and write a test in it called legal_e2() to check out that the following sequence of commands returns the expected response.

Commands:

/start classical fen
/legal e2

Response:

{"\/legal":{"color":"w","id":"P","fen":{"e3":"rnbqkbnr\/pppppppp\/8\/8\/8\/4P3\/PPPP1PPP\/RNBQKBNR b KQkq -","e4":"rnbqkbnr\/pppppppp\/8\/8\/4P3\/8\/PPPP1PPP\/RNBQKBNR b KQkq e3"}}}

Keep it up,

I am interested in it and I have started working on it.
I just want to task, do I have to also run the command /start classical fen in legal_e2 function.
I am just asking because there is already a test case that does it for us.

I have opened a PR, kindly see and let me know if it's alright or do I need to make some improvments.

@kaifkh20 it seems as though this issue needs some elaboration.

See:

Stay tuned!

Interesting..

I have found an another way of solving this issue without the need to rewrite the function..
Screenshot at 2023-10-04 21-02-37

In this, I have included the file StartCommandTest.php so that it can be used later in our file.

Screenshot at 2023-10-04 21-07-22

In this, I instantiated the object of StartCommand class and called the setUp function of that class inside our class so that it can be used right out of the box and then created a test function first which calls that function and then added a depended test which is our legal command test function.

Thank you @kaifkh20,

Can you please paste the code in a comment or commit the changes to the pull request branch?

Keep it up,

l have commited in my pr.
Kindly see..