CodingAvenue / codestop-proof-lib-php

A PHP library for creating awesome CA Academy courses proofs (@TenshiLyle)
0 stars 0 forks source link

Allow Proof writer to test their own Proof files #12

Closed TenshiLyle closed 7 years ago

TenshiLyle commented 7 years ago

Proof writers need to unit tests their proof files locally. We should allow them to pass a path to a php file on the Code constructor. If nothing is passed, then the default ./code will be used.

TenshiLyle commented 7 years ago

@sandaemc I will implement this in a different way, which would probably require the user of the Code() class to pass an optional path to their test file. The debug_backtrace() isn't full proof since we cannot control where the user will instantiate the Code class. E.g. did it call directly from a proof file? Or parent class? Or maybe up on the hierarchy?

sandaemc commented 7 years ago

How about we put it in a config file and have our library automatically use what's specified in the config file? The default would be /code. Then if the user want to override it they would just add a config file.

TenshiLyle commented 7 years ago

@sandaemc not sure I understand this completely. What is on the config?

sandaemc commented 7 years ago

The proof library will look for a config like proof.json in the base directory of where the proof library was installed as dependency.

proof.json should just be optional. Example content of the config:

{
    "codeFilePath": "/code",
    "verbose": true
}
TenshiLyle commented 7 years ago

So does this mean that authors will have to update the config file each time they will test their proof?

sandaemc commented 7 years ago

No, I was thinking of another layer for that. Sorry, I was solving another problem. So we have two problems:

Adding config will solve the former. For the latter, nothing yet.

TenshiLyle commented 7 years ago

Created #17 for the config

sandaemc commented 7 years ago

Let's try this.

Here's the pseudo code

./proof-tester tests/BeautifulWorldTest.php

// Inside the test runner
 - Provided a file or a glob, find the counterpart answers
 - Copy the answer and paste it into whatever path in proof.json
 - Run phpunit tests/BeautifulWorldTest.php

The downside of this approach, is that the tests are run individually in a loop. But I think that is okay.

TenshiLyle commented 7 years ago

@sandaemc seems like this isn't going to be part of the php-proof then but on the course file. Or are we generating the test runner for them?

sandaemc commented 7 years ago

The runner will be part of proof lib

https://getcomposer.org/doc/articles/vendor-binaries.md

TenshiLyle commented 7 years ago

I'll merge #17 with this one. The plan is to make the test runner look for a proof.json at the current directory. Use it if it's available. Otherwise use the default settings.