Преглед на файлове

Add fixtures for sortable test

Lukas Botsch преди 13 години
родител
ревизия
c3b4b32188
променени са 2 файла, в които са добавени 80 реда и са изтрити 0 реда
  1. 43 0
      tests/Gedmo/Sortable/Fixture/Author.php
  2. 37 0
      tests/Gedmo/Sortable/Fixture/Paper.php

+ 43 - 0
tests/Gedmo/Sortable/Fixture/Author.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace Sortable\Fixture;
+
+use Gedmo\Mapping\Annotation as Gedmo;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity(repositoryClass="Gedmo\Sortable\Entity\Repository\SortableRepository")
+ */
+class Author
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(name="name", type="string")
+     */
+    private $name;
+
+    /**
+     * @Gedmo\SortableGroup
+     * @ORM\ManyToOne(targetEntity="Paper", inversedBy="authors")
+     */
+    private $paper;
+
+    /**
+     * @Gedmo\SortablePosition
+     * @ORM\Column(name="position", type="integer")
+     */
+    private $position;
+
+    public function getName() { return $this->name; }
+    public function setName($name) { $this->name = $name; }
+    public function getPaper() { return $this->paper; }
+    public function setPaper($paper) { $this->paper = $paper; }
+    public function getPosition() { return $this->position; }
+    public function setPosition($position) { $this->position = $position; }
+}

+ 37 - 0
tests/Gedmo/Sortable/Fixture/Paper.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Sortable\Fixture;
+
+use Gedmo\Mapping\Annotation as Gedmo;
+use Doctrine\ORM\Mapping as ORM;
+use Doctrine\Common\Collections\ArrayCollection;
+
+/**
+ * @ORM\Entity
+ */
+class Paper
+{
+    /**
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     * @ORM\Column(type="integer")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(name="name", type="string")
+     */
+    private $name;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Author", mappedBy="paper", cascade={"persist", "remove"})
+     */
+    private $authors;
+
+    public function __construct() { $this->authors = new ArrayCollection(); }
+    public function getId() { return $this->id; }
+    public function getName() { return $this->name; }
+    public function setName($name) { $this->name = $name; }
+    public function getAuthors() { return $this->authors; }
+    public function addAuthor($author) { $this->authors->add($author); }
+}