* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @covers App\Controller\TimeController * @uses App\Entity\Entry * @uses App\Service\ActiveEntry */ class TimeControllerTest extends WebTestCase { /** * @test */ public function rootCanBeOpened() { $client = static::createClient(); $crawler = $client->request('GET', '/'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextContains('h1', 'Time entries'); } /** * @test */ public function newEntryCanBeStarted() { $client = static::createClient(); $client->request('GET', '/'); $client->submitForm('Start', ['title' => 'Test Entry']); $this->assertResponseRedirects('/'); $client->request('GET', '/'); $this->assertResponseIsSuccessful(); $this->assertInputValueSame('title', 'Test Entry'); } /** * @test */ public function runningEntryCanBeStopped() { $client = static::createClient(); $client->request('GET', '/'); $client->submitForm('Start', ['title' => 'Test Entry']); $client->request('GET', '/'); $client->submitForm('Stop'); $this->assertResponseRedirects('/'); $client->request('GET', '/'); $this->assertResponseIsSuccessful(); $this->assertInputValueSame('title', ''); $this->assertSelectorTextSame('button', 'Start'); } /** * @test */ public function noneRunningEntryCanBeStopped() { $client = static::createClient(); $client->request('POST', '/stop'); $this->assertResponseRedirects('/'); $client->request('GET', '/'); $this->assertResponseIsSuccessful(); $this->assertInputValueSame('title', ''); $this->assertSelectorTextSame('button', 'Start'); } }