public function testToOptionArray() { $expect = [['label' => __('-- Please Select a Category --'), 'value' => ''], ['label' => 'name', 'value' => 3]]; $this->categoryCollection->expects($this->once())->method('addAttributeToSelect')->with($this->equalTo('name'))->will($this->returnValue($this->categoryCollection)); $this->categoryCollection->expects($this->once())->method('addRootLevelFilter')->will($this->returnValue($this->categoryCollection)); $this->categoryCollection->expects($this->once())->method('load'); $this->categoryCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->category]))); $this->category->expects($this->once())->method('getName')->will($this->returnValue('name')); $this->category->expects($this->once())->method('getId')->will($this->returnValue(3)); $this->assertEquals($expect, $this->model->toOptionArray()); }
public function testChildrenUrlPathAttributeNoUpdatingIfParentUrlPathIsNotChanged() { $this->categoryUrlPathGenerator->expects($this->any())->method('getUrlKey')->willReturn('url_key'); $this->categoryUrlPathGenerator->expects($this->any())->method('getUrlPath')->willReturn('url_path'); $this->categoryResource->expects($this->once())->method('saveAttribute')->with($this->category, 'url_path'); $this->category->expects($this->any())->method('getUrlKey')->willReturn('not_formatted_url_key'); $this->category->expects($this->any())->method('setUrlKey')->willReturnSelf(); $this->category->expects($this->any())->method('setUrlPath')->willReturnSelf(); $this->category->expects($this->once())->method('isObjectNew')->willReturn(false); // break code execution $this->category->expects($this->once())->method('dataHasChangedFor')->with('url_path')->willReturn(false); $this->categoryUrlPathAutogeneratorObserver->execute($this->observer); }
public function testAfterSaveScheduled() { $this->categoryResourceMock->expects($this->once())->method('addCommitCallback'); $this->assertEquals($this->categoryResourceMock, $this->model->aroundSave($this->categoryResourceMock, $this->proceed, $this->categoryMock)); }