/** * @test */ public function dirtyPersist() { $storage = new NullStorage(); $model = new ModelFixture(); $model->foo = 1; $model->markAsStored(); $storage->persist($model); }
/** * @test */ public function purge() { $client = $this->getQueryResultMock(); $client->expects($this->atLeastOnce())->method('update'); $storage = new ElasticSearchStorage($client, 'foo', 'bar'); $model = new ModelFixture(); $model->foo = 'test'; $model->id = 10; $model->markAsStored(); $model->foo = 'test2'; $storage->persist($model); $this->assertFalse($model->isDirty()); }
/** * @test */ public function purge() { $solrResultMock = $this->getMockBuilder('\\Solarium\\QueryType\\Update\\Result')->disableOriginalConstructor()->getMock(); $solrResultMock->expects($this->any())->method('getStatus')->will($this->returnValue(0)); $solrQueryMock = $this->getMockBuilder('\\Solarium\\QueryType\\Update\\Query\\Query')->getMock(); $solrQueryMock->expects($this->atLeastOnce())->method('addDeleteById'); $client = $this->getQueryResultMock(); $client->expects($this->any())->method('createUpdate')->will($this->returnValue($solrQueryMock)); $client->expects($this->atLeastOnce())->method('update')->will($this->returnValue($solrResultMock)); $storage = new SolrStorage($client, 'foo', 'bar'); $model = new ModelFixture(); $model->foo = 'test'; $model->id = 1; $model->markAsStored(); $storage->purge($model); }
/** * @test * @expectedException \Systream\Repository\Storage\Exception\NothingDeletedException */ public function purgeWithNullId() { $pdo = $this->getPDO(); $this->createTestTable($pdo); $storage = new SqlStorage($pdo, 'test'); $model = new ModelFixture(); $model->foo = 'test'; $model->id = null; $model->markAsStored(); $storage->purge($model); }