-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #426 from jackalope/binary-cascade
delete binary when property is deleted
- Loading branch information
Showing
11 changed files
with
131 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,3 @@ phpcr_tests.db-journal | |
|
||
vendor/ | ||
composer.lock | ||
|
||
/test |
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
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
58 changes: 58 additions & 0 deletions
58
tests/Jackalope/Transport/DoctrineDBAL/DeleteCascadeTest.php
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,58 @@ | ||
<?php | ||
|
||
namespace Jackalope\Transport\DoctrineDBAL; | ||
|
||
use Doctrine\DBAL\Platforms\SqlitePlatform; | ||
use Jackalope\Test\FunctionalTestCase; | ||
use PHPCR\PropertyType; | ||
|
||
class DeleteCascadeTest extends FunctionalTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) { | ||
$this->markTestSkipped('Foreign keys are not supported with sqlite'); | ||
} | ||
|
||
$a = $this->session->getNode('/')->addNode('node-a'); | ||
$a->setProperty('data', 'foo', PropertyType::BINARY); | ||
$this->session->save(); | ||
} | ||
|
||
public function testRemoveProperty(): void | ||
{ | ||
$binaryRows = $this->conn->executeQuery('SELECT * FROM phpcr_binarydata'); | ||
$this->assertSame(1, $binaryRows->rowCount()); | ||
|
||
$this->session->removeItem('/node-a/data'); | ||
$this->session->save(); | ||
$binaryRows = $this->conn->executeQuery('SELECT * FROM phpcr_binarydata'); | ||
$this->assertSame(0, $binaryRows->rowCount()); | ||
} | ||
|
||
public function testRemovePropertyFromNode(): void | ||
{ | ||
$a = $this->session->getNode('/node-a'); | ||
$binaryRows = $this->conn->executeQuery('SELECT * FROM phpcr_binarydata'); | ||
$this->assertSame(1, $binaryRows->rowCount()); | ||
|
||
$a->getProperty('data')->remove(); | ||
$this->session->save(); | ||
$binaryRows = $this->conn->executeQuery('SELECT * FROM phpcr_binarydata'); | ||
$this->assertSame(0, $binaryRows->rowCount()); | ||
} | ||
|
||
public function testRemoveNode(): void | ||
{ | ||
$a = $this->session->getNode('/node-a'); | ||
$binaryRows = $this->conn->executeQuery('SELECT * FROM phpcr_binarydata'); | ||
$this->assertSame(1, $binaryRows->rowCount()); | ||
|
||
$a->remove(); | ||
$this->session->save(); | ||
$binaryRows = $this->conn->executeQuery('SELECT * FROM phpcr_binarydata'); | ||
$this->assertSame(0, $binaryRows->rowCount()); | ||
} | ||
} |
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