Testing on Laravel

73b0a25ed03f649ec63ded82ce4ac7cb?s=47 nunulk
January 31, 2019

Testing on Laravel

73b0a25ed03f649ec63ded82ce4ac7cb?s=128

nunulk

January 31, 2019
Tweet

Transcript

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

  2. ࣗݾ঺հ w ໊લOVOVML ͵͵Δ͘  w ৬ۀϑϦʔϥϯεͷ΢ΣϒΞϓϦέʔγϣϯΤϯδχΞ w ࢓ࣄͰ࢖͏ݴޠ΍ϑϨʔϜϫʔΫ
 1)1

    -BSBWFM +BWB4DSJQU 5ZQF4DSJQU 7VFKT w ޷͖ͳݴޠ1)1 /JN $MPKVSF
  3. ࠷ۙͷؔ৺ࣄ

  4. ςετॻ͍ͯ·͔͢ʁ

  5. 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
  6. 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'
 ]);
  7. 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', ], ]; }
  8. 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();
  9. Mocking DI $mockService = \Mockery::mock(‘SomeService')
 ->shouldReturn('someMethod')
 ->once()
 ->andReturn(1)
 ->getMock(); 


    $this->app->bind(SomeService::class,
 function () use ($mockService) { return $mockService; }
 );