public function testUpdateIngredientType()
 {
     $args = array("name" => "anotherIngredient");
     $response = $this->executeRequest(array("id" => 1, "values" => $args), true);
     $this->verifyOk($response, 204);
     $ingredient = ingredientTypeQuery::create()->findPk(1);
     $this->assertEquals("anotherIngredient", $ingredient->getname());
 }
 public function testCreateIngredientType()
 {
     $args = array("name" => "newIngredient");
     $response = $this->executeRequest($args, true);
     $this->verifyOk($response);
     $result = $response->json();
     $created = ingredientTypeQuery::create()->findPk($result["id"]);
     $this->assertEquals("newIngredient", $created->getname());
 }
<?php

session_start();
require_once '../../bootstrap.php';
require '../../services/UserService.php';
require '../../services/ForeignService.php';
UserService::withRole(UserService::$CONTRIBUTOR, function () {
    if (array_key_exists("id", $_GET)) {
        $ingredientId = $_GET["id"];
        $ingredient = ingredientTypeQuery::create()->findPk($ingredientId);
    }
    $force = false;
    if (array_key_exists("force", $_GET)) {
        $force = $_GET["force"];
    }
    if (isset($ingredient)) {
        try {
            $databaseName = unitPeer::DATABASE_NAME;
            $constraints = array("ingredient" => "ingredientId");
            if ($force == true) {
                ForeignService::forceForeignConstraints($databaseName, $constraints, $ingredientId, true);
                $ingredient->delete();
                http_response_code(204);
            } else {
                $result = ForeignService::verifyForeignConstraints($databaseName, $constraints, $ingredientId);
                if ($result) {
                    $ingredient->delete();
                    http_response_code(204);
                } else {
                    echo json_encode(array("result" => "Cet ingredient est référencée dans les ingredients de recette."));
                }
<?php

require_once '../../bootstrap.php';
$query = ingredientTypeQuery::create()->select(array('id', 'name'))->orderByName()->find();
$data = $query->getData();
echo json_encode($data);
?>