public function testCreateWhenKeyDefinedAndIsUnique() { $generator = new DefaultBranchKeyGenerator(); $crawler = $this->client->request('GET', $this->getUrl('diamante_branch_create')); /** @var Form $form */ $form = $crawler->selectButton('Save and Close')->form(); $branchName = md5(time()); $branchKey = $generator->generate($branchName) . 'ABC'; $form['diamante_branch_form[name]'] = $branchName; $form['diamante_branch_form[key]'] = $branchKey; $form['diamante_branch_form[description]'] = 'Test Description'; $this->client->followRedirects(true); $crawler = $this->client->submit($form); $response = $this->client->getResponse(); $this->assertEquals(200, $response->getStatusCode()); $this->assertContains("Branch successfully created.", $crawler->html()); $this->assertTrue($crawler->filter('html:contains("' . $branchKey . '")')->count() == 1); }
/** * @dataProvider validDataProvider * @param string $branchName * @param string $key */ public function testGenerate($branchName, $key) { $generator = new DefaultBranchKeyGenerator(); $generatedKey = $generator->generate($branchName); $this->assertEquals($key, $generatedKey); }