public function testTableMode() { $this->collection->method('valid')->will($this->onConsecutiveCalls(true, true, false)); $this->collection->method('current')->will($this->onConsecutiveCalls(MockObjectWrapper::fromObject($this->instances[0]), MockObjectWrapper::fromObject($this->instances[1]))); $_GET['mode'] = Admin::MODE_TABLE; $_SERVER['REQUEST_URI'] = '.'; $admin = AdminBuilder::begin()->setId("test-page")->addQuery($this->query)->build(); $writables = $admin->getWritables(); $this->assertInstanceOf(TableInterface::class, $writables[0]->getWritables()[0]->getWritables()[1]); $table = $writables[0]->getWritables()[0]->getWritables()[1]; $this->assertEquals(sizeof($this->instances) + 1, sizeof($table->getRows())); }
public function testRelationFilterByRelation() { $this->collection->method('valid')->will($this->onConsecutiveCalls(true, true, false)); $this->collection->method('current')->will($this->onConsecutiveCalls(MockObjectWrapper::fromObject($this->instances[0]), MockObjectWrapper::fromObject($this->instances[1]))); $filter = FilterBuilder::begin()->setId('test-relation-filter')->setType(Filter::TYPE_RELATION)->setQuery($this->query)->setDefault(RelationFilter::ALL)->build(); $this->query->expects($this->once())->method("filterBy")->with($this->equalTo('MyObject.MyObjectId'), $this->equalTo(QueryWrapperInterface::CONDITION_EQUAL), $this->equalTo(null)); $_GET['test-relation-filter-value'] = base64_encode($this->instances[0]->getPrimaryKey()); $filter->queryFilter(new MockQueryWrapper($this->query)); unset($_GET['test-relation-filter-value']); }
public function createObject() { return MockObjectWrapper::fromObject(new MockObject($this->query->titleCasedObjectName, [], null, [])); }