Skip to content

Instantly share code, notes, and snippets.

@demental
Last active December 18, 2015 16:39
Show Gist options
  • Save demental/5812742 to your computer and use it in GitHub Desktop.
Save demental/5812742 to your computer and use it in GitHub Desktop.
<?php
class ActionListTest extends PHPUnit_Framework_TestCase
{
public function setup()
{
$this->subject = $this->getMock('MOfficeActionLister',array('allActions'));
$this->subject->expects($this->any())
->method('allActions')
->will($this->mockAllActions());
}
public function aSingleAction() {
return array(
'name' => 'action2',
'title' => 'other test title',
'batch' => false,
'single' => true
);
}
public function aBatchAction() {
return array(
'name' => 'action1',
'title' => 'test title',
'batch' => true,
'single' => false
);
}
public function mockAllActions()
{
return $this->returnValue(array($this->aBatchAction(), $this->aSingleAction()));
}
public function testSingleActions()
{
$this->assertEqual(
array($this->aSingleAction()),
$this->subject->singleActions()
);
}
}
describe MOfficeActionLister do
describe '#singleactions' do
let(:a_batch_action) do
{
name: 'action1',
title: 'test title',
batch: true,
single: false
}
end
let(:a_single_action) do
{
name: 'action2',
title: 'another test title',
batch: false,
single: true
}
end
let(:all_actions) { [a_batch_action, a_single_action] }
before { subject.stub(:allActions).and_return all_actions}
subject { MOfficeActionLister.new }
its(:singleActions) { should eq [a_single_action] }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment