forked from claroline/CoreBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing organisations users & locations fields.
- Loading branch information
1 parent
46788d6
commit ca5989d
Showing
7 changed files
with
107 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Claroline\CoreBundle\Migrations\pdo_mysql; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated migration based on mapping information: modify it with caution | ||
* | ||
* Generation date: 2016/02/25 05:42:14 | ||
*/ | ||
class Version20160225174213 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema) | ||
{ | ||
$this->addSql(" | ||
CREATE TABLE claro__location_organization ( | ||
organization_id INT NOT NULL, | ||
location_id INT NOT NULL, | ||
INDEX IDX_C4EBDE032C8A3DE (organization_id), | ||
INDEX IDX_C4EBDE064D218E (location_id), | ||
PRIMARY KEY(organization_id, location_id) | ||
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro__location_organization | ||
ADD CONSTRAINT FK_C4EBDE032C8A3DE FOREIGN KEY (organization_id) | ||
REFERENCES claro__organization (id) | ||
ON DELETE CASCADE | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro__location_organization | ||
ADD CONSTRAINT FK_C4EBDE064D218E FOREIGN KEY (location_id) | ||
REFERENCES claro__location (id) | ||
ON DELETE CASCADE | ||
"); | ||
$this->addSql(" | ||
DROP TABLE claro_user_organization | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro_user_administrator | ||
DROP PRIMARY KEY | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro_user_administrator | ||
ADD PRIMARY KEY (organization_id, user_id) | ||
"); | ||
} | ||
|
||
public function down(Schema $schema) | ||
{ | ||
$this->addSql(" | ||
CREATE TABLE claro_user_organization ( | ||
organization_id INT NOT NULL, | ||
user_id INT NOT NULL, | ||
INDEX IDX_9F29A0F732C8A3DE (organization_id), | ||
INDEX IDX_9F29A0F7A76ED395 (user_id), | ||
PRIMARY KEY(organization_id, user_id) | ||
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro_user_organization | ||
ADD CONSTRAINT FK_9F29A0F732C8A3DE FOREIGN KEY (organization_id) | ||
REFERENCES claro__organization (id) | ||
ON DELETE CASCADE | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro_user_organization | ||
ADD CONSTRAINT FK_9F29A0F7A76ED395 FOREIGN KEY (user_id) | ||
REFERENCES claro_user (id) | ||
ON DELETE CASCADE | ||
"); | ||
$this->addSql(" | ||
DROP TABLE claro__location_organization | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro_user_administrator | ||
DROP PRIMARY KEY | ||
"); | ||
$this->addSql(" | ||
ALTER TABLE claro_user_administrator | ||
ADD PRIMARY KEY (user_id, organization_id) | ||
"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ protected function setUp() | |
$this->persister->persist($this->admin); | ||
$this->persister->flush(); | ||
} | ||
|
||
/* | ||
//@route: api_post_organization | ||
//@url: /api/organizations.{_format} | ||
//@method: POST | ||
|
@@ -159,25 +159,27 @@ public function testGetEditOrganizationFormActionIsProtected() | |
$this->logIn($this->john); | ||
$this->client->request('GET', "/api/edits/{$orga->getId()}/organization/form.json"); | ||
$this->assertEquals(403, $this->client->getResponse()->getStatusCode()); | ||
} | ||
}*/ | ||
|
||
//@route: api_put_organization | ||
//@url: /api/organizations/{organization}.{_format} | ||
public function testPutOrganizationAction() | ||
{ | ||
$orga = $this->persister->organization('orga'); | ||
$orga = $this->persister->organization('orga'); | ||
$here = $this->persister->location('here'); | ||
$this->persister->flush(); | ||
$this->logIn($this->admin); | ||
$fields = array( | ||
'name' => 'rename', | ||
'email' => '[email protected]', | ||
'administrators' => $this->admin->getId() | ||
'administrators' => $this->admin->getId(), | ||
'locations' => array($here->getId()) | ||
); | ||
$form = array('organization_form' => $fields); | ||
|
||
$this->client->request('PUT', "/api/organizations/{$orga->getId()}.json", $form); | ||
$data = $this->client->getResponse()->getContent(); | ||
$data = json_decode($data, true); | ||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
} | ||
|
||
//@route: api_put_organization | ||
|