Skip to content

Commit

Permalink
convert tests to use attributes instead of annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Dec 3, 2023
1 parent 552d4a3 commit ba5abaf
Show file tree
Hide file tree
Showing 27 changed files with 312 additions and 432 deletions.
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@
namespace Doctrine\ODM\PHPCR\Document;

use Doctrine\ODM\PHPCR\HierarchyInterface;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* This class represents an abstract "file"
*/
#[ODM\MappedSuperclass(mixins: ['mix:created'])]
#[PHPCR\MappedSuperclass(mixins: ['mix:created'])]
abstract class AbstractFile implements HierarchyInterface
{
#[ODM\Id(strategy: 'parent')]
#[PHPCR\Id(strategy: 'parent')]
protected $id;

#[ODM\Node]
#[PHPCR\Node]
protected $node;

#[ODM\Nodename]
#[PHPCR\Nodename]
protected $nodename;

#[ODM\ParentDocument]
#[PHPCR\ParentDocument]
protected $parent;

#[ODM\Field(property: 'jcr:created', type: 'date')]
#[PHPCR\Field(property: 'jcr:created', type: 'date')]
protected $created;

#[ODM\Field(property: 'jcr:createdBy', type: 'string')]
#[PHPCR\Field(property: 'jcr:createdBy', type: 'string')]
protected $createdBy;

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ODM/PHPCR/Document/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
namespace Doctrine\ODM\PHPCR\Document;

use Doctrine\ODM\PHPCR\Exception\RuntimeException;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* This class represents a JCR file, aka nt:file.
*
* @see http://wiki.apache.org/jackrabbit/nt:file
*/
#[ODM\Document(nodeType: 'nt:file', mixins: [], referenceable: true)]
#[PHPCR\Document(nodeType: 'nt:file', mixins: [], referenceable: true)]
class File extends AbstractFile
{
/**
* @var Resource
*/
#[ODM\Child(nodeName: 'jcr:content', cascade: 'all')]
#[PHPCR\Child(nodeName: 'jcr:content', cascade: 'all')]
protected $content;

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/PHPCR/Document/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\PHPCR\HierarchyInterface;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;

/**
* This class represents a Folder in the repository, aka nt:folder
Expand All @@ -32,19 +32,19 @@
* To add files or folders to a folder, create the new File/Folder and set
* this document as parent, then persist the new File/Folder.
*/
#[ODM\Document(nodeType: 'nt:folder', mixins: [])]
#[PHPCR\Document(nodeType: 'nt:folder', mixins: [])]
class Folder extends AbstractFile
{
/**
* @var ArrayCollection
*/
#[ODM\Children(cascade: 'all')]
#[PHPCR\Children(cascade: 'all')]
protected $children;

/**
* @var AbstractFile
*/
#[ODM\Child(cascade: 'all')]
#[PHPCR\Child(cascade: 'all')]
protected $child;

/**
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/PHPCR/Document/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;
use PHPCR\NodeInterface;

/**
Expand All @@ -30,31 +30,31 @@
* It is used as a default document, for example with the ParentDocument annotation.
* You can not use this to create nodes as it has no type annotation.
*/
#[ODM\Document]
#[PHPCR\Document]
class Generic
{
#[ODM\Id(strategy: 'parent')]
#[PHPCR\Id(strategy: 'parent')]
protected $id;

#[ODM\Node]
#[PHPCR\Node]
protected $node;

#[ODM\Nodename]
#[PHPCR\Nodename]
protected $nodename;

#[ODM\ParentDocument]
#[PHPCR\ParentDocument]
protected $parent;

/**
* @var Collection
*/
#[ODM\Children]
#[PHPCR\Children]
protected $children;

/**
* @var Collection
*/
#[ODM\MixedReferrers]
#[PHPCR\MixedReferrers]
protected $referrers;

/**
Expand Down
22 changes: 11 additions & 11 deletions lib/Doctrine/ODM/PHPCR/Document/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,45 @@
namespace Doctrine\ODM\PHPCR\Document;

use Doctrine\ODM\PHPCR\Exception\BadMethodCallException;
use Doctrine\ODM\PHPCR\Mapping\Attributes as ODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;
use PHPCR\NodeInterface;

/**
* This class represents a jcr nt:resource and is used by the File document
*
* @see http://wiki.apache.org/jackrabbit/nt:resource
*/
#[ODM\Document(nodeType: 'nt:resource')]
#[PHPCR\Document(nodeType: 'nt:resource')]
class Resource
{
#[ODM\Id]
#[PHPCR\Id]
protected $id;

/**
* @var NodeInterface
*/
#[ODM\Node]
#[PHPCR\Node]
protected $node;

#[ODM\Nodename]
#[PHPCR\Nodename]
protected $nodename;

#[ODM\ParentDocument]
#[PHPCR\ParentDocument]
protected $parent;

#[ODM\Field(property: 'jcr:data', type: 'binary')]
#[PHPCR\Field(property: 'jcr:data', type: 'binary')]
protected $data;

#[ODM\Field(property: 'jcr:mimeType', type: 'string')]
#[PHPCR\Field(property: 'jcr:mimeType', type: 'string')]
protected $mimeType = 'application/octet-stream';

#[ODM\Field(property: 'jcr:encoding', type: 'string', nullable: true)]
#[PHPCR\Field(property: 'jcr:encoding', type: 'string', nullable: true)]
protected $encoding;

#[ODM\Field(property: 'jcr:lastModified', type: 'date')]
#[PHPCR\Field(property: 'jcr:lastModified', type: 'date')]
protected $lastModified;

#[ODM\Field(property: 'jcr:lastModifiedBy', type: 'string')]
#[PHPCR\Field(property: 'jcr:lastModifiedBy', type: 'string')]
protected $lastModifiedBy;

/**
Expand Down
90 changes: 36 additions & 54 deletions tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\ODM\PHPCR\Exception\RuntimeException;
use Doctrine\ODM\PHPCR\Id\IdException;
use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface;
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR;
use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase;
use PHPCR\NodeInterface;
use PHPCR\PropertyType;
Expand Down Expand Up @@ -660,81 +660,71 @@ public function testChangeset(): void
}
}

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class User
{
/** @PHPCRODM\Id */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Node */
#[PHPCR\Node]
public $node;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;

/** @PHPCRODM\Field(type="string", nullable=true) */
#[PHPCR\Field(type: 'string', nullable: true)]
public $note;

/** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */
#[PHPCR\Field(type: 'long', multivalue: true, nullable: true)]
public $numbers;

/** @PHPCRODM\Field(type="string", assoc="", nullable=true) */
#[PHPCR\Field(type: 'string', assoc: '', nullable: true)]
public $parameters;

/** @PHPCRODM\Field(type="long", assoc="", nullable=true) */
#[PHPCR\Field(type: 'long', assoc: '', nullable: true)]
public $assocNumbers;
}

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class User2
{
/** @PHPCRODM\Id */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;
}

/**
* @PHPCRODM\Document(repositoryClass="Doctrine\Tests\ODM\PHPCR\Functional\User3Repository")
*/
#[PHPCR\Document(repositoryClass: User3Repository::class)]
class User3
{
/** @PHPCRODM\Id(strategy="repository") */
#[PHPCR\Id(strategy: 'repository')]
public $id;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;
}

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class User5
{
/** @PHPCRODM\Nodename */
#[PHPCR\Nodename]
public $nodename;

/** @PHPCRODM\ParentDocument */
#[PHPCR\ParentDocument]
public $parent;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;

/** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */
#[PHPCR\Field(type: 'long', multivalue: true, nullable: true)]
public $numbers;
}

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class User6 extends User5
{
/** @PHPCRODM\Id(strategy="auto") */
#[PHPCR\Id(strategy: 'auto')]
public $id;
}

Expand All @@ -753,56 +743,48 @@ public function generateId($document, $parent = null)
}
}

/**
* @PHPCRODM\Document()
*/
#[PHPCR\Document]
class TeamUser extends User
{
/** @PHPCRODM\ParentDocument */
#[PHPCR\ParentDocument]
public $parent;
}

/**
* @PHPCRODM\Document(versionable="full")
*/
#[PHPCR\Document(versionable: 'full')]
class VersionTestObj
{
/** @PHPCRODM\Id */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Node */
#[PHPCR\Node]
public $node;

/** @PHPCRODM\VersionName */
#[PHPCR\VersionName]
public $versionName;

/** @PHPCRODM\VersionCreated */
#[PHPCR\VersionCreated]
public $versionCreated;

/** @PHPCRODM\Field(type="string") */
#[PHPCR\Field(type: 'string')]
public $username;

/** @PHPCRODM\Field(type="long", multivalue=true, nullable=true) */
#[PHPCR\Field(type: 'long', multivalue: true, nullable: true)]
public $numbers;
}

/**
* @PHPCRODM\Document(referenceable=true)
*/
#[PHPCR\Document(referenceable: true)]
class UserWithUuid extends User
{
/** @PHPCRODM\Uuid */
#[PHPCR\Uuid]
public $uuid;
}

/**
* @PHPCRODM\Document
*/
#[PHPCR\Document]
class DepthMappingObject
{
/** @PHPCRODM\Id */
#[PHPCR\Id]
public $id;

/** @PHPCRODM\Depth */
#[PHPCR\Depth]
public $depth;
}
Loading

0 comments on commit ba5abaf

Please sign in to comment.