public function createDatabase() { $em = $this->doctrineContainer->getEntityManager(); $tool = new \Doctrine\ORM\Tools\SchemaTool($em); $tool->dropDatabase(); $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); $usuario = new \Application\Entity\Usuario(); $usuario->setNome('admin'); $usuario->setEnergia(100); $usuario->setEnergiaMaxima(100); $usuario->setEmail('*****@*****.**'); $usuario->setSenha('123'); $em->persist($usuario); $em->flush(); self::$created = true; }
/** * Initialize required variables once for all tests. */ public static function setUpBeforeClass() { static::$resourceModel = new ResourceModel(parent::getPDO()); parent::setGlobalVariables(); }
public function setUp() { parent::setUp(); }
public function setUp() { $modelTest = new ModelTestCase(); $modelTest->setUp(); $this->doctrineContainer = $modelTest->doctrineContainer; }
/** * Test copyParticipant function when the users have already joined the event. */ public function testCopyParticipantDuplicate() { // This should not insert any records since the participants already joined the event static::$eventModel->copyParticipant(1, 2); $expectedTable = (new PHPUnit_ArrayDataSet(array('Participant' => array(parent::createParticipantObject(2, 1, 0), parent::createParticipantObject(2, 2, 0)))))->getTable('Participant'); $actualTable = $this->getConnection()->createQueryTable('Participant', 'SELECT * FROM Participant WHERE EventID = 2'); $this->assertEquals(4, $this->getConnection()->getRowCount('Participant')); $this->assertTablesEqual($expectedTable, $actualTable); }
/** * Constructs the test case. */ public function __construct() { parent::__construct(); // empty }
/** * Test the normal usage for insertUserTag function. */ public function testInsertUserTag() { static::$userModel->insertUserTag(1, 6); $expectedTable = (new PHPUnit_ArrayDataSet(array('UserTag' => array(parent::createUserTagObject(1, 1), parent::createUserTagObject(1, 5), parent::createUserTagObject(1, 6)))))->getTable('UserTag'); $actualTable = $this->getConnection()->createQueryTable('UserTag', 'SELECT * FROM UserTag WHERE UserID = 1'); $this->assertEquals(4, $this->getConnection()->getRowCount('UserTag')); $this->assertTablesEqual($expectedTable, $actualTable); }