Slide 1

Slide 1 text

Testing on Laravel nunulk Laravel/Vue.jsษڧձ#7

Slide 2

Slide 2 text

ࣗݾ঺հ w ໊લOVOVML ͵͵Δ͘ w ৬ۀϑϦʔϥϯεͷ΢ΣϒΞϓϦέʔγϣϯΤϯδχΞ w ࢓ࣄͰ࢖͏ݴޠ΍ϑϨʔϜϫʔΫ
 1)1 -BSBWFM +BWB4DSJQU 5ZQF4DSJQU 7VFKT w ޷͖ͳݴޠ1)1 /JN $MPKVSF

Slide 3

Slide 3 text

࠷ۙͷؔ৺ࣄ

Slide 4

Slide 4 text

ςετॻ͍ͯ·͔͢ʁ

Slide 5

Slide 5 text

Laravel Testing Tips w 1)16OJU w BTTFSU&RVBMT BTTFSU4BNF BTTFSU5SVF BTTFSU'BMTF BTTFSU$POUBJOT BTTFSU/VMM BTTFSU5IBU BTTFSU"SSBZ)BT,FZ FUD w !EBUB1SPWJEFS !FYQFDUFE&YDFQUJPO !HSPVQ FUD w -BSBWFM w .PDLFSZ 'BLFS w .PEFM'BDUPSZ'BDLFS w 'BDBEF.PDLFSZ w %*$POUBJOFS w *OUFSBDUT8JUI"VUIFOUJDBUJPO .PDLT"QQMJDBUJPO4FSWJDFT *OUFSBDUT8JUI%BUBCBTF3FGSFTI%BUBCBTF %BUBCBTF5SBOTBDUJPOT FUD w BDUJOH"T BTTFSU%BUBCBTF)BT BTTFSU%BUBCBTF.JTTJOH FUD

Slide 6

Slide 6 text

Assertions $this->assertNotSame(1, ‘1'); $this->assertTrue(true); $this->assertContains('PHP', 'PHPUnit'); $this->assertNotContains(2, [1, 3, 5, 7, 9]); $this->assertNotNull(1); $this->assertArrayHasKey('Laravel', [
 'PHP' => '7.2',
 'Laravel' => ‘5.7'
 ]);

Slide 7

Slide 7 text

DataProvider /** * @param string $key1 * @param string $key2 * @return void * @dataProvider dataSomething */ public function testSomething(string $key1, string $key2) {
 }
 public function dataSomething() { return [ 'OK' => [ 'key1' => 'value1', 'key2' => 'value2', ], 'NG:έʔε1' => [ 'key1' => 'value3', 'key2' => 'value4', ], ]; }

Slide 8

Slide 8 text

Model Factory + Faker $factory->define(App\Task::class, function (Faker $faker) { return [ 'subject' => $faker->text(), 'status' => 'open', ‘priority' => 'normal', ]; }); $factory->state(App\Task::class, 'doing', [ 'status' => 'doing', ]); $factory->state(App\Task::class, ‘high', [ 'priority' => 'high', ]); $task = factory(Task::class)->states([‘doing’,’high'])->make();

Slide 9

Slide 9 text

Mocking DI $mockService = \Mockery::mock(‘SomeService')
 ->shouldReturn('someMethod')
 ->once()
 ->andReturn(1)
 ->getMock(); 
 $this->app->bind(SomeService::class,
 function () use ($mockService) { return $mockService; }
 );