public function test_view_models_are_identical_with_first_registered_by_calling_they_many_times_without_any_optional_name() { $this->repo->registerModel('Foo', 1); $this->repo->registerModel('Foo', 123); $foo = $this->repo->getFoo(); $this->assertInstanceOf('ViewModelServiceTest\\TestAsset\\ViewModel\\FooViewModel', $foo); $this->assertSame(array(1), $foo->getBuildArgs()); $this->assertSame($foo, $this->repo->getFoo()); }
public function test_view_models_registered_by_same_way_are_not_identical_by_calling_them_by_using_returned_id() { $id1 = $this->repo->addFoo(1); $id2 = $this->repo->addFoo(2); $id3 = $this->repo->addFoo(3); $id4A = $this->repo->addFoo(4, 'A'); $id5B = $this->repo->addFoo(5, 'B'); $ids6A = $this->repo->addSuper(6, 'A'); $ids7B = $this->repo->addSuper(7, 'B'); $this->assertSame('Foo', $id1); $this->assertSame($id4A, 'FooA'); $this->assertSame($id5B, 'FooB'); $this->assertSame($ids6A, 'SuperA'); $this->assertSame($ids7B, 'SuperB'); $this->assertNotEquals('Foo', $id2); $this->assertNotEquals('Foo', $id3); $this->assertNotEquals('Foo', $id4A); $this->assertNotEquals('Foo', $id5B); $this->assertNotEquals($id1, $id2); $this->assertNotEquals($id1, $id3); $this->assertNotEquals($id1, $id4A); $this->assertNotEquals($id1, $id5B); $this->assertNotEquals($id2, $id3); $this->assertNotEquals($id2, $id4A); $this->assertNotEquals($id2, $id5B); $this->assertNotEquals($id3, $id4A); $this->assertNotEquals($id3, $id5B); $this->assertNotEquals($id4A, $id5B); $this->assertSame(1, $this->repo->getFoo($id1)->input[0]); $this->assertSame(1, $this->repo->getFoo()->input[0]); $this->assertSame(2, $this->repo->getFoo($id2)->input[0]); $this->assertSame(3, $this->repo->getFoo($id3)->input[0]); $this->assertSame(4, $this->repo->getFoo($id4A)->input[0]); $this->assertSame(4, $this->repo->getFoo('A')->input[0]); $this->assertSame(5, $this->repo->getFoo($id5B)->input[0]); $this->assertSame(5, $this->repo->getFoo('B')->input[0]); }