public function testNewConnection() { $this->repository->selectContentType('example01'); $record = $this->repository->getRecord(1); $this->assertEquals(5, $record->getRevision()); $this->assertEquals('example01', $record->getContentTypeName()); $this->assertEquals(1, $record->getID()); $this->assertEquals('New Record 1 - Revision 5', $record->getName()); $this->assertEquals('Test 1', $record->getProperty('article')); $records = $this->repository->getRecords(); $this->assertCount(5, $records); $this->assertEquals(5, $this->repository->countRecords()); }
public function testSaveRecords() { $this->repository->selectContentType('example01'); for ($i = 1; $i <= 5; $i++) { $record = $this->repository->createRecord('New Record ' . $i); $record->setProperty('article', 'Test ' . $i); $id = $this->repository->saveRecord($record); $this->assertEquals($i, $id); } $this->repository->selectLanguage('es'); for ($i = 1; $i <= 5; $i++) { $record = $this->repository->createRecord('New Record ' . (5 + $i)); $record->setProperty('article', 'Test ' . (5 + $i)); $id = $this->repository->saveRecord($record); $this->assertEquals(5 + $i, $id); } $this->repository->selectWorkspace('live'); for ($i = 1; $i <= 5; $i++) { $record = $this->repository->createRecord('New Record ' . (10 + $i)); $record->setProperty('article', 'Test ' . (10 + $i)); $id = $this->repository->saveRecord($record); $this->assertEquals(10 + $i, $id); } $this->repository->reset(); $c = $this->repository->countRecords(); $this->assertEquals(5, $c); $this->repository->selectLanguage('es'); $c = $this->repository->countRecords(); $this->assertEquals(5, $c); $this->repository->selectWorkspace('live'); $c = $this->repository->countRecords(); $this->assertEquals(5, $c); $this->repository->selectLanguage('default'); $c = $this->repository->countRecords(); $this->assertEquals(0, $c); }
public function testGetRecords() { $repository = new Repository('phpunit', $this->connection); $repository->selectContentType('example01'); $records = $repository->getRecords(); $this->assertCount(5, $records); $this->assertEquals(5, $repository->countRecords()); $i = 0; foreach ($records as $id => $record) { $i++; $this->assertEquals($i, $id); $this->assertEquals('Test ' . $i, $record->getProperty('article')); } $repository->registerRecordClassForContentType('example01', 'AnyContent\\Client\\AlternateRecordClass'); $records = $repository->getRecords(); $i = 0; foreach ($records as $id => $record) { $i++; $this->assertInstanceOf('AnyContent\\Client\\AlternateRecordClass', $record); $this->assertEquals($i, $id); $this->assertEquals('New Record ' . $i, $record->getName()); $this->assertEquals('Test ' . $i, $record->getProperty('article')); } }
public function countRecords($filter = '') { return parent::countRecords($filter); }