public function testUpdateCountry()
 {
     $args = array("name" => "anotherCountry", "flag" => "http://www.drapeauxdespays.fr/data/flags/mini/sm.png");
     $response = $this->executeRequest(array("id" => 1, "values" => $args), true);
     $this->verifyOk($response, 204);
     $country = countryQuery::create()->findPk(1);
     $this->assertEquals("anotherCountry", $country->getname());
     $this->assertEquals("http://www.drapeauxdespays.fr/data/flags/mini/sm.png", $country->getflag());
 }
 public function testCreateCountry()
 {
     $args = array("name" => "newCountry", "flag" => "http://www.drapeauxdespays.fr/data/flags/mini/sm.png");
     $response = $this->executeRequest($args, true);
     $this->verifyOk($response);
     $result = $response->json();
     $created = countryQuery::create()->findPk($result["id"]);
     $this->assertEquals("newCountry", $created->getname());
     $this->assertEquals("http://www.drapeauxdespays.fr/data/flags/mini/sm.png", $created->getflag());
 }
<?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)) {
        $countryId = $_GET["id"];
        $country = countryQuery::create()->findPk($countryId);
    }
    $force = false;
    if (array_key_exists("force", $_GET)) {
        $force = $_GET["force"];
    }
    if (isset($country)) {
        try {
            $databaseName = countryPeer::DATABASE_NAME;
            $constraints = array("recipes" => "origin");
            if ($force == true) {
                ForeignService::forceForeignConstraints($databaseName, $constraints, $countryId);
                $country->delete();
                http_response_code(204);
            } else {
                $result = ForeignService::verifyForeignConstraints($databaseName, $constraints, $countryId);
                if ($result) {
                    $country->delete();
                    http_response_code(204);
                } else {
                    echo json_encode(array("result" => "Ce pays est référencé par des recettes."));
                }
<?php

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