0, 'prop2' => 'hello' ); } } class DataStoreTest extends TestCase { protected function setUp() { RedBean::initStubs(); $this->instance = new DataStoreMock(); } public function testContructor() { $this->instance->store(); $newInstance = new DataStoreMock($this->instance->getBeanInstance()); $this->assertEquals(0, $newInstance->prop1); $this->assertEquals('hello', $newInstance->prop2); } public function testDataStoreCustomData() { $this->instance->setProperties(array( 'prop3' => 'EXTRA_DATA' )); $this->assertEquals(0, $this->instance->prop1); $this->assertEquals('hello', $this->instance->prop2); $this->assertEquals('EXTRA_DATA', $this->instance->prop3); } public function testStore() { $this->instance->store(); $this->assertTrue(RedBean::get('store')->hasBeenCalled()); } public function testGetDataStore() { RedBean::setStatics(array( 'findOne' => \Mock::stub()->returns(new BeanMock(['prop1' => 'TEST_VALUE'])) )); $dataStoreIntance = DataStoreMock::getDataStore('ID_VALUE'); $this->assertEquals('TEST_VALUE', $dataStoreIntance->prop1); $this->assertTrue(RedBean::get('findOne')->hasBeenCalledWithArgs( 'MOCK_TABLE', 'id =:value', array( ':value' => 'ID_VALUE' ) )); } public function testDeleteDataStore() { $this->instance->delete(); $this->assertTrue(RedBean::get('trash')->hasBeenCalledWithArgs($this->instance->getBeanInstance())); } }