26 private $viewSuffix =
"<suffix>";
29 private $itemTreeBounds;
31 protected function setUp()
33 $this->itemTreeBounds = M::mock(ItemTreeBounds::class);
36 public function testDefaultViewName()
38 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
42 assertThat($uploadTreeView->getDbViewName(), is(
"UploadTreeView"));
45 public function testViewName()
47 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
49 $uploadTreeView =
new UploadTreeViewProxy($this->itemTreeBounds, array(), $this->viewSuffix);
51 assertThat($uploadTreeView->getDbViewName(), is(
"UploadTreeView.<suffix>"));
54 public function testWithoutCondition()
56 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
60 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM foo"));
63 public function testWithoutConditionAndDefaultTable()
65 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"uploadtree_a");
66 $this->itemTreeBounds->shouldReceive(
"getUploadId")->once()->withNoArgs()->andReturn(23);
70 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM uploadtree_a WHERE upload_fk = 23"));
73 public function testWithoutConditionAndMasterTable()
75 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"uploadtree");
76 $this->itemTreeBounds->shouldReceive(
"getUploadId")->once()->withNoArgs()->andReturn(23);
80 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM uploadtree WHERE upload_fk = 23"));
83 public function testWithUploadCondition()
85 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
86 $this->itemTreeBounds->shouldReceive(
"getUploadId")->once()->withNoArgs()->andReturn(76);
88 $uploadTreeView =
new UploadTreeViewProxy($this->itemTreeBounds, array(UploadTreeViewProxy::CONDITION_UPLOAD));
90 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM foo WHERE upload_fk = 76"));
93 public function testWithDoubleUploadCondition()
95 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
96 $this->itemTreeBounds->shouldReceive(
"getUploadId")->once()->withNoArgs()->andReturn(76);
98 $uploadTreeView =
new UploadTreeViewProxy($this->itemTreeBounds, array(UploadTreeViewProxy::CONDITION_UPLOAD, UploadTreeViewProxy::CONDITION_UPLOAD));
100 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM foo WHERE upload_fk = 76"));
103 public function testWithRangeCondition()
105 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
106 $this->itemTreeBounds->shouldReceive(
"getLeft")->once()->withNoArgs()->andReturn(25);
107 $this->itemTreeBounds->shouldReceive(
"getRight")->once()->withNoArgs()->andReturn(50);
109 $uploadTreeView =
new UploadTreeViewProxy($this->itemTreeBounds, array(UploadTreeViewProxy::CONDITION_RANGE));
111 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM foo WHERE lft BETWEEN 25 AND 50"));
114 public function testWithPlainFilesCondition()
116 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
118 $uploadTreeView =
new UploadTreeViewProxy($this->itemTreeBounds, array(UploadTreeViewProxy::CONDITION_PLAIN_FILES));
120 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM foo WHERE ((ufile_mode & (3<<28))=0) AND pfile_fk != 0"));
123 public function testWithMultipleConditions()
125 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
126 $this->itemTreeBounds->shouldReceive(
"getUploadId")->once()->withNoArgs()->andReturn(5);
127 $this->itemTreeBounds->shouldReceive(
"getLeft")->once()->withNoArgs()->andReturn(22);
128 $this->itemTreeBounds->shouldReceive(
"getRight")->once()->withNoArgs()->andReturn(43);
130 $uploadTreeView =
new UploadTreeViewProxy($this->itemTreeBounds, array(UploadTreeViewProxy::CONDITION_UPLOAD, UploadTreeViewProxy::CONDITION_PLAIN_FILES, UploadTreeViewProxy::CONDITION_RANGE));
132 assertThat($uploadTreeView->getDbViewQuery(), is(
"SELECT * FROM foo WHERE upload_fk = 5 AND ((ufile_mode & (3<<28))=0) AND pfile_fk != 0 AND lft BETWEEN 22 AND 43"));
141 $this->itemTreeBounds->shouldReceive(
"getUploadTreeTableName")->once()->withNoArgs()->andReturn(
"foo");
testExcpetionWithUnknownConstraint()