Skip to content
Snippets Groups Projects
Commit dc7ba7ed authored by Yghore's avatar Yghore
Browse files
parents 2f9c5009 6b64c57e
No related branches found
No related tags found
No related merge requests found
......@@ -20,5 +20,5 @@ build-job: # Le job se lance dans la phase de build
unit-test-job: # Le job se lance dans la phase de test
stage: test
script:
- echo "Running unit tests"
\ No newline at end of file
- php vendor/bin/codecept generate:cest Acceptance Premier
- php vendor/bin/codecept run --steps
<?php
class Faker
{
private array $code = ['Filter a array and exclude element if key is "chapeau"', 'Check if word is a palindromic word', 'return a number of occurence for word into a text'];
private array $test = ["If you're using JavaScript, you can use the filter method to exclude elements with a key of 'chapeau'. Here's an example:",
"A palindromic word is a word that reads the same backward as forward. To check if a word is a palindromic word, you can compare its reverse to the original word. Here's an example in JavaScript:",
"To return the number of occurrences of a word in a text, you can use the split method to convert the text into an array of words, and then use the filter method to count the number of elements in the array that match the target word. Here's an example in JavaScript:"];
public int $number;
public function __construct()
{
$this->number = rand(0, sizeof($this->code)-1);
}
public function getCode(): string
{
return $this->code[$this->number];
}
public function getTest(): string
{
return $this->test[$this->number];
}
public function regenerateCode(): void
{
$this->number = rand(1, sizeof($this->code));
}
}
\ No newline at end of file
<?php
require_once('Faker.php');
class OPenAIGenerator
{
private string $question;
......@@ -12,6 +13,11 @@ class OPenAIGenerator
{
$this->usefaker = $useFaker;
$this->question = $question;
if($useFaker)
{
$fakerClasse = new Faker();
$this->setFaker($fakerClasse);
}
if($generateCode)
{
$this->code = $this->genCode();
......@@ -19,10 +25,10 @@ class OPenAIGenerator
$this->test = $this->genTest();
}
public function setFaker($faker) // SPECIFY CLASS OF FAKER FOR RETURN TYPE
public function setFaker($fakerClasse) // SPECIFY CLASS OF FAKER FOR RETURN TYPE
{
// TO DOO SET FAKER CLASSE
$this->faker = $faker;
$this->faker = $fakerClasse;
}
public function genCode(): string
......@@ -42,7 +48,7 @@ class OPenAIGenerator
{
// TO DOO
// USE CLASS FAKER FOR RETURN STRING
return "";
return $this->faker->getCode();
}
}
......@@ -63,7 +69,7 @@ class OPenAIGenerator
{
// TO DOO
// USE CLASS FAKER FOR RETURN STRING
return "";
return $this->faker->getTest();
}
}
......
namespace: Tests
support_namespace: Support
paths:
tests: tests
output: tests/_output
data: tests/Support/Data
support: tests/Support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
This diff is collapsed.
......@@ -21,7 +21,7 @@ HTMLEOF;
if(!empty($_POST['question']))
{
$gen = new OpenAIGenerator($_POST['question']);
$gen = new OpenAIGenerator($_POST['question'], true ,true);
echo $gen;
}
else
......
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost/myapp
# add Codeception\Step\Retry trait to AcceptanceTester to enable retries
step_decorators:
- Codeception\Step\ConditionalAssertion
- Codeception\Step\TryTo
- Codeception\Step\Retry
<?php
namespace Tests\Acceptance;
use Tests\Support\AcceptanceTester;
class PremierCest
{
public function _before(AcceptanceTester $I)
{
}
// tests
public function tryToTest(AcceptanceTester $I)
{
}
}
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony, Yii2, Laravel, Phalcon5) to use it
# Remove this suite if you don't use frameworks
actor: FunctionalTester
modules:
enabled:
# add a framework module here
step_decorators: ~
<?php
declare(strict_types=1);
namespace Tests\Support;
/**
* Inherited Methods
* @method void wantTo($text)
* @method void wantToTest($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}
<?php
declare(strict_types=1);
namespace Tests\Support;
/**
* Inherited Methods
* @method void wantTo($text)
* @method void wantToTest($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}
<?php
declare(strict_types=1);
namespace Tests\Support;
/**
* Inherited Methods
* @method void wantTo($text)
* @method void wantToTest($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}
*
!.gitignore
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.
actor: UnitTester
modules:
enabled:
- Asserts
step_decorators: ~
*
!.gitignore
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment