AugustMiller / rick

Command Line Tools for Kirby CMS
0 stars 1 forks source link

Test #13

Open jackjennings opened 9 years ago

jackjennings commented 9 years ago

So far there are two ideas that I have for where automated tests would be most beneficial:

I'd like this to be a pretty opinionated setup, so that it's not necessary to mess around with phpunit config, and we can reliably generate tests scaffolding alongside blueprints, controllers, and templates.

AugustMiller commented 9 years ago

How does a controller test work? Deep object comparison of data we know to be correct?

Without just duplicating the code in the controller (i.e. fetching the same data outside the scope of the controller), I don't know how we could evaluate its success.

jackjennings commented 9 years ago

I'd imagine that it would have to be something like:

public function testShouldHaveSlideshow() {
  $this->page = $this->mockPage($someArgs);

  $data = $this->controller($this->site, $this->pages, $this->page);

  $this->assertNotNull($data['slideshow']);
}

$this->site, $this->pages, and $this->page would need to be some kind of mock objects that could be manipulated to test that certain outcomes were possible when running the controller function.

Not sure what you mean about duplicating the code in the controller?