Beispiel #1
0
 protected function setUp()
 {
     $this->repository = $this->getMockBuilder('Trismegiste\\SocialBundle\\Repository\\PublishingRepository')->disableOriginalConstructor()->getMock();
     $this->repository->expects($this->any())->method('create')->will($this->returnValue($this->createData()));
     $validator = Validation::createValidator();
     $type = $this->createType();
     $this->factory = Forms::createFormFactoryBuilder()->addExtension(new ValidatorExtension($validator))->addType(new PublishingType($this->repository))->addType($type)->getFormFactory();
     $this->sut = $this->factory->create($type->getName());
 }
Beispiel #2
0
 public function testRepeatAndPersist()
 {
     $another = new Author('spock');
     $source = $this->getMockBuilder('Trismegiste\\Socialist\\Publishing')->setConstructorArgs([$another])->setMethods(null)->getMock();
     $pk = '54390582e3f43405428b4568';
     $this->repository->expects($this->once())->method('findByPk')->with($this->equalTo($pk))->will($this->returnValue($source));
     $this->repository->expects($this->once())->method('persist');
     $this->sut->repeatPublishing($pk);
 }
 /**
  * @test
  */
 public function initialize()
 {
     $this->collection->drop();
     $this->assertCount(0, $this->collection->find());
     $this->addUserFixture('kirk');
     $this->addUserFixture('spock');
     $this->logIn('kirk');
     $pub = $this->contentRepo->create('small');
     $pub->setMessage('message' . static::$random);
     $this->contentRepo->persist($pub);
     return $pub->getId();
 }
 public function testDeleteStrategy()
 {
     $strat = $this->getMock('Trismegiste\\SocialBundle\\Repository\\DeletePub\\DeleteStrategyInterface');
     $strat->expects($this->once())->method('remove')->with($this->document);
     $this->sut->addDeleteStrategy('message', $strat);
     $id = '54390582e3f43405428b4568';
     $this->repository->expects($this->once())->method('findByPk')->with($this->equalTo($id))->will($this->returnValue($this->document));
     $this->sut->delete($id);
 }